Hello,
I`m new around here, so please accept my appologies if this has already been discussed to death!
I`m writing a small program to allow me to remotely restart/shutdown computers over my works network.
For the Client sode, I created a small window with three gadgets in it at the moment.  Then my program waits for a WindowEvent to happen, when it does this, it then checks which gadgetevent happened.  Everything OK so far.
My program then deals with what ever it was supposed to do (eg sent the shutdown message) and then returns to the main loop.  This is where the problem starts.
My program then checks for a WindowEvent then a GadgetEvent, then does the same thing again, this happens over and over, until I terminate the program.
It seems that it still thinks an event has happened (which it has), but I`ve alreay dealt with it.  How do I clear the Events?
Best Regards,
Frank.
			
			
									
									
						Gadget Events
- 
				CaptainFrank
- User 
- Posts: 16
- Joined: Sun Sep 21, 2003 2:20 pm
- Location: In front of my Monitor :)
Re: Gadget Events
> How do I clear the Events? 
Are you using WaitWindowEvent() or WindowEvent() ?
In any event (LOL!) you can clear pending events by doing this:
			
			
									
									
						Are you using WaitWindowEvent() or WindowEvent() ?
In any event (LOL!) you can clear pending events by doing this:
Code: Select all
While WindowEvent() : Wend
- 
				CaptainFrank
- User 
- Posts: 16
- Joined: Sun Sep 21, 2003 2:20 pm
- Location: In front of my Monitor :)
Re: Gadget Events
Hi,PB wrote:> How do I clear the Events?
Are you using WaitWindowEvent() or WindowEvent() ?
I`m doing it like this :
Code: Select all
Repeat
WaitWindowEvent()
       Select EventGadgetID()
               Case 1
               Case 2 etc.....
Your While - Went worked fine for the WindowEvent however, when I move the mouse back over the window (causing a window event) the EventGadgetID() is still set to the old value and therefore triggers the same button again, even though I haven`t pressed any buttons.
I tried a while - wend for the EventGadgetID() but it just goes round in an infinate loop.
Best Regards,
Frank.
you have to check the result of WaitWindowEvent()
if it returns #PB_EventGadget, then check for the gadget event.
EventGadgetID() will return the same value until another
#PB_EventGadget is returned from WaitWindowEvent()
like this:
This code will process the Gadget events correctly, and exit, as soon
as the user pressed the 'X' button of the window. (use #PB_Window_SystemMenu
at OpenWindow() to make the 'X' buttton appear.
Timo
			
			
									
									if it returns #PB_EventGadget, then check for the gadget event.
EventGadgetID() will return the same value until another
#PB_EventGadget is returned from WaitWindowEvent()
like this:
Code: Select all
Repeat
  Event.l = WaitWindowEvent()
  If Event = #PB_EventGadget
    Select EventGadgetID()
      ; ...
    EndSelect
  Endif
Until Event = #PB_EventCloseWindow
as the user pressed the 'X' button of the window. (use #PB_Window_SystemMenu
at OpenWindow() to make the 'X' buttton appear.
Timo
quidquid Latine dictum sit altum videtur
						- 
				CaptainFrank
- User 
- Posts: 16
- Joined: Sun Sep 21, 2003 2:20 pm
- Location: In front of my Monitor :)
