Windows sends timer input to your application when the specified interval elapses for a particular timer. To receive timer input, you must set a timer by using the SetTimer function.
You can receive timer input in two ways:
Windows can place a WM_TIMER message in your application's queue.
Windows can call a callback function defined in your application. You specify the callback function when you call the SetTimer function.
The following example shows how to set timer input for a five-second interval:
idTimer = SetTimer (hWnd, 1, 5000, (FARPROC) NULL);
Summary: Your application receives timer input through its application queue.
This example sets a timer interval of 5,000 milliseconds. This means that the timer will generate input every five seconds. The second argument is any nonzero value that your application uses to identify the particular timer. The last argument specifies the callback function that will receive timer input. Setting this argument to NULL tells Windows to provide timer input as a WM_TIMER message. Because there is no callback function specified for timer input, Windows sends the timer input through the application queue.
The SetTimer function returns a “timer ID”—an integer that identifies the timer. You can use this timer ID to turn the timer off by using it in the KillTimer function.