1. wxEuphoria: Why Does this Proggie Crash?

Matt, I sent this to you via email, but I suspect you check here more
frequently. :)

I'm getting an error running the following:

-- i've basically just used the drawing_primitives.exw code we developed...
-- so i don't understand why i get the error.

without warning
include wxEuphoria.e
include wxGraphics.e
include wxButton.e
include wxTimer.e

constant
   win_Test = create( wxFrame, {0,-1,"GUI Graphics Test", -1, -1, -1, -1} )
   , bttn_StartStop = create( wxButton, {win_Test,-1,"Start", -1, -1, -1, -1})
   , drawBox = create( wxPanel, {win_Test})
   , DrawTimer   = create( wxTimer, {drawBox, -1} )

integer timing, playing, counter
   timing = (1=2)
   playing = (1=2)
   counter = 0
   procedure TogglePlay( atom this, atom event_type, atom id, atom event )
   if this = bttn_StartStop then -- start/stop the dots
       playing = not playing
       if playing then
           -- set button text to "Stop"
           set_button_label( bttn_StartStop, "Stop" )
           -- start timer
           start_timer( DrawTimer, 1, 1 )
           counter = 0
       else
           -- set button text to "Start"
           -- stop timer
           stop_timer( DrawTimer )
           set_button_label( bttn_StartStop, "Start" )
       end if
   end if
end procedure
set_event_handler( bttn_StartStop, get_id(bttn_StartStop),
wxEVT_COMMAND_BUTTON_CLICKED, routine_id("TogglePlay"))

procedure onTimer( atom this, atom event_type, atom id, atom event )
atom dc
object VOID
   dc = create( wxClientDC, {drawBox} )
   begin_drawing(dc)
       while playing do
           counter += 1
           wx_puts( dc, sprintf("%d",{counter}))
           -- let other events happen:
           VOID = call_member( wxApp_Yield, myApp_this, {1})
       end while
   end_drawing(dc)
   delete_instance(dc)
end procedure
set_event_handler( drawBox, -1, wxEVT_TIMER, routine_id("onTimer"))

wxMain( win_Test )


-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » topic index » view message » categorize

2. Re: wxEuphoria: Why Does this Proggie Crash?

cklester wrote:
> 
> Matt, I sent this to you via email, but I suspect you check here more
> frequently. :)
> 
> I'm getting an error running the following:
> 
The problem is the wx_puts() statement.  If you only supply an atom as
an argument, it assumes that it's a window in a paint event and creates
a dc for you.  You need to change it to something like:
wx_puts( {drawBox, 10, 10, dc}, sprintf("%d",{counter}))


Of course, you'll need to give a position and size to drawBox.  Also, the
way it's set up right now, it just writes over itself.

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu