STARTTIMER

Top  Previous  Next

Syntax

STARTTIMER(win as WINDOW,time as UINT,OPT id=1 as INT,OPT callback as UINT)

Description

Starts a timer in a window or dialog.

Parameters

win - Window or dialog

time - Timer interval in milliseconds

id - Optional timer id, defaults to 1.

callback - Optional timer callback address.

Return value

None

Remarks

The callback is an address of a subroutine to be called whenever the timer elapses. The subroutine must be declared as:

 

SUB name(hwnd as UINT, msg as UINT, idEvent as UINT, dwTime as UINT)

'name' can be anything you wish. hwnd will be the handle of the window that contains the timer, msg will always be @IDTIMER, idEvent is the timer id specified in the STARTTIMER statement and dwTime is the current system time in milliseconds.

If a callback address is not specified then the timer will send an @IDTIMER message to your window procedure at every interval. In this case @CODE (@WPARAM) will contain the timer id.

See Also: STOPTIMER

Example usage

'Start a timer with a callback
STARTTIMER win, 1000, 1, &mytimer
'Start a timer that sends @IDTIMER messages.
STARTTIMER win, 5000, 3