WindowEvent()

Syntax

Event = WindowEvent()
Description
Check if an event has occured on any of the opened windows. This function returns immediately, so be careful to not stole the whole CPU power with a non temporized loop... (a good solution is to use the Delay() command with at least 1 millisecond as parameter at the end of your loop).
To lock the program execution, just use the WaitWindowEvent() command. To get the window number in which the event occurred, you need to use the EventWindowID() function.

Possible Events are :
  #PB_Event_Menu           : a menu has been selected
  #PB_Event_Gadget         : a gadget has been pushed
  #PB_Event_CloseWindow    : the window close gadget has been pushed
  #PB_Event_Repaint        : the window content has been destroyed and must be repained (useful for 2D graphics operations)
  #PB_Event_SizeWindow     : the window has been resized
  #PB_Event_MoveWindow     : the window has been moved
  #PB_Event_ActivateWindow : the window has been activated (got the focus)
You find a basic example for event handling at WaitWindowEvent().

The correct way to handle an WindowEvent() loop is something like that:
  Repeat 
    Event = WindowEvent() 

    If Event    ; An event was in the queue so process it 
      .... 
    Else  
      Delay(1)  ; No event, let the others apps get some CPU time too ! 
    EndIf 
  Until Event = #PB_Event_CloseWindow
Note: The 'Delay' shouldn't be put after each event, because when lot of events will come (like refresh, gadgets updates etc..) the app will wait 20 ms (on windows at least) between each event. So the delay need to be put when no events are received. Another (API) way is to use a timer and stick with WaitWindowEvent().

Supported OS

All

<- WaitWindowEvent() - Window Index - WindowHeight() ->