WM_TIMER

2.x

WM_TIMER
wTimerID = wParam;                   /* timer identifier              */
tmprc = (TIMERPROC FAR*) lParam;     /* address of timer callback     */

The WM_TIMER message is posted to the installing application's message queue or sent to the appropriate TimerProc callback function after each interval specified in the SetTimer function used to install a timer.

Parameters

wTimerID

Value of wParam. Specifies the identifier of the timer.

tmprc

Value of lParam. Points to a callback function that was passed to the SetTimer function when the timer was installed. If the tmprc parameter is not NULL, the system passes the WM_TIMER message to the specified callback function rather than posting the message to the application's message queue.

Return Value

An application should return zero if it processes this message.

Comments

The DispatchMessage function sends this message when no other messages are in the application's message queue.

Example

This example uses the WM_TIMER message to create a blinking effect for a line of text:

DWORD dwXYVal;
WORD wXVal, wYVal;
char szMessage[16];

case WM_TIMER:
    hdc = GetDC(hwnd);
    dwXYVal = GetTextExtent(hdc, (LPCSTR) szMessage,
        lstrlen(szMessage));
    wXVal = LOWORD(dwXYVal);
    wYVal = HIWORD(dwXYVal);
    PatBlt(hdc, 10, 10, (int) wXVal, (int) wYVal, PATINVERT);
    ReleaseDC(hwnd, hdc);
    ValidateRect(hwnd, NULL);
    break;

See Also

SetTimer, TimerProc