SetTimer

  UINT SetTimer(hwnd, idTimer, uTimeout, tmprc)    
  HWND hwnd; /* handle of window for timer messages */
  UINT idTimer; /* timer identifier */
  UINT uTimeout; /* time-out duration */
  TIMERPROC tmprc; /* address of timer procedure */

The SetTimer function installs a system timer. A time-out value is specified, and every time a time-out occurs, the system posts a WM_TIMER message to the installing application's message queue or passes the message to an application-defined TimerProc callback function.

Parameters

hwnd

Identifies the window to be associated with the timer. If the tmprc parameter is NULL, the window procedure associated with this window receives the WM_TIMER messages generated by the timer. If this parameter is NULL, no window is associated with the timer.

idTimer

Specifies a nonzero timer identifier. If the hwnd parameter is NULL, this parameter is ignored.

uTimeout

Specifies the time-out value, in milliseconds.

tmprc

Points to the function to be notified when the timer event takes place. If tmprc is NULL, the WM_TIMER message is placed in the application queue, and the hwnd member of the MSG structure contains the hwnd parameter given in the SetTimer function call. For more information, see the description of the TimerProc callback function.

Return Value

The return value specifies the integer identifier for the new timer event. If the hwnd parameter is NULL, an application passes this value to the KillTimer function to kill the timer event. The return value is zero if the timer was not created.

Comments

Timers are a limited global resource; therefore, it is important that an application check the value returned by the SetTimer function to verify that a timer is actually available.

See Also

KillTimer