AddWindowTimer(#Window, Timer, Timeout)
Adds a new timer to the specified window. BindEvent() can be used with #PB_Event_Timer to get the event. RemoveWindowTimer() function can be used to remove the timer.


#Window The window to use. A timer is always attached to a window and will be removed if that window is closed.
Timer An user-defined number that identifies this timer. Timers on separate windows may have overlapping numbers. This value will later be returned from EventTimer() when a #PB_Event_Timer is received. It can also be used to remove the timer again with the RemoveWindowTimer() function.
Timeout Specifies the amount of time (in milliseconds) between each #PB_Event_Timer events. The timer events will only be generated when there are no other events to be processed (timers are low-priority events). This means that the time that elapses between two timer events may be larger than the specified Timeout value. Timers are therefore not suited for precise timing but are rather intended to perform periodic tasks such as updating a gadget content or similar.

Return value



  Procedure TimerEvents()
    Debug "Timer event: " + EventTimer()
  If OpenWindow(0, 0, 0, 295, 260, "Timer example", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
    AddWindowTimer(0, 0, 1000) ; First timer every seconds
    AddWindowTimer(0, 1, 3000) ; Second timer every 3 seconds
    BindEvent(#PB_Event_Timer, @TimerEvents())

See Also

RemoveWindowTimer(), EventTimer()

Supported OS


<- AddKeyboardShortcut() - Window Index - BindEvent() ->