Page 1 of 1

Posted: Sun Mar 23, 2003 6:45 am
by BackupUser
Restored from previous forum. Originally posted by LJ.

Take the code below. Notice the erradict and generally unresponsiveness of the mouse. Sometimes the words "test image" are drawn on the first click, and sometimes not. Worse, try closing the window, sometimes the window closes on the first click, and sometimes it takes several. Anyone have any ideas?

OpenWindow(1, 0, 0, 796, 560, #PB_Window_SystemMenu, "Test")
CreateGadgetList(WindowID())
CreateImage(1, WindowWidth(), WindowHeight())
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(LoadFont(0, "Times New Roman", 16))
Locate(64, 32)
DrawText("Background image")
StopDrawing()
ImageGadget(1, 0, 0, WindowWidth(), WindowHeight(), UseImage(1))
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")

LoadFont(0, "Times New Roman", 16)

Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()

Case 0
Gosub UpdateWindow

EndSelect
EndIf

Until WaitWindowEvent()=#PB_EventCloseWindow
End

UpdateWindow:
FreeGadget(0)
UseImage(1)
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(UseFont(0))
Locate(64, 32)
DrawText("Test image")
StopDrawing()
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")
SetGadgetState(1, UseImage(1))
ActivateGadget(0)
Return

Posted: Sun Mar 23, 2003 7:38 am
by BackupUser
Restored from previous forum. Originally posted by momo.

Hi!
I had the same mistake yesterday so I know now how to do it.:)
You wrote "WaitWindowEvent()" twice so both of them wait for an event but sometimes only one registred an event that's why you sometimes had to push twice!
Here the new code( only change EventID instead of WaitWindowEvent after the Until):


OpenWindow(1, 0, 0, 796, 560, #PB_Window_SystemMenu, "Test")
CreateGadgetList(WindowID())
CreateImage(1, WindowWidth(), WindowHeight())
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(LoadFont(0, "Times New Roman", 16))
Locate(64, 32)
DrawText("Background image")
StopDrawing()
ImageGadget(1, 0, 0, WindowWidth(), WindowHeight(), UseImage(1))
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")

LoadFont(0, "Times New Roman", 16)

Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()

Case 0
Gosub UpdateWindow

EndSelect
EndIf

Until Eventid =#PB_EventCloseWindow
End

UpdateWindow:
FreeGadget(0)
UseImage(1)
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(UseFont(0))
Locate(64, 32)
DrawText("Test image")
StopDrawing()
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")
SetGadgetState(1, UseImage(1))
ActivateGadget(0)
Return

I hope it'll help!

Moritz

Don't Look so stupid
I've got no Signature!!

Posted: Sun Mar 23, 2003 7:38 am
by BackupUser
Restored from previous forum. Originally posted by wayne1.

Change:
Until WaitWindowEvent()=#PB_EventCloseWindow
to:
Until EventID=#PB_EventCloseWindow

Posted: Sun Mar 23, 2003 4:44 pm
by BackupUser
Restored from previous forum. Originally posted by LJ.

Thank you Wayne and Momo. :)