[Overview][Types][Procedures and functions][Variables][Index] | Reference for unit 'LCLIntf' (#lcl)

# SetTimer

Creates or resets an timer for the given time interval.

## Declaration

Source position: winapih.inc line 357

`function SetTimer(`
`Wnd: HWND;`
`nIDEvent: UINT_PTR;`
`uElapse: UINT;`
`lpTimerFunc: TTimerProc`
`):UINT_PTR;`

## Arguments

`Wnd` |  | The window associated with the timer.
`nIDEvent` |  | The ID of the timer, ignored when Wnd is zero.
`uElapse` |  | The time interval to wait.
`lpTimerFunc` |  | The callback procedure, can be Nil.

## Function result

The timer ID, or zero on failure.

## Description

Every timer has a unique ID, which is reported in the timer message and can be used to reset or kill the timer.

When the time has elapsed, the callback procedure is invoked. If no procedure is given, a WM_TIMER message is sent to the window. If also no window is given, the function fails.

When the timer already exists, it is reset to the new interval.

## See also

KillTimer |  | Removes an timer.
TTimerProc |  | Defines a procedure used as a callback to process timer messages.