The SETTIMER function is defined in the MSDN.
Timer Function Creates A Timer with the specified time-out value.
// setTimer function Creates a timer that specifies time intervals
Syntax
Uint_ptr settimer (hwnd hwnd,
UINT_PTR NIDEVENT,
UINT UELAPSE,
TimerProc LPTIMERFUNC
);
Parameters
HWnd
[in] Handle to the window to be associated with the Timer. this window thread. if calling thread. if Tim Parameter Is Null, NO WINDOW IS Associated with the Timer and Thae
Nidevent parameter is ignored.
/ / Point to a window associated with the timer, this window must have a thread that calls the timer. If this parameter is null, the Timer's ID will be ignored, that is, the Timer invalid.
Nidevent
[in] Specifies a nonzero Timer Identifier. if The
HWnd Parameter Is Null, this parameter is ignored. if the
HWND Parameter Is Not Null and The Window Specified by
HWnd Already Has A Timer with The Value
NidEvent, Then the EXISTING TIMER IS Replaced by the New Timer. by
Settimer Replaces A Timer, The Timer Is Reset. Theur, a Message Will Be Sent After The Current Time-Out value ELAPSES, But The Previously Set Time-out value is ignored.
// This function will be ignored, if the parameter
HWnd is NULL, if the system already has a Timer ID and this new set of IDs, then this new id will replace the old id, when the current time slice is coming, a message will be sent, the previous time The value set will be canceled.
UELAPSE
.
/ / Specify time interval
Windows NT / 2000 / XP: IF UELAPSE IS GREATER THAN USER_TIMER_MAXIMUM, The Timeout IS set to 1.
Windows 2000 / XP: IF UELAPSE IS LESS THAN USER_TIMER_MINIMUM, TIMEOUT IS set to user_timer_minimum.
Windows Server 2003: IF UELAPSE IS GREATER THAN USER_TIMER_MAXIMUM, TIMEOUT IS set to user_timer_maximum.
Windows XP SP2 / Windows Server 2003 SP1: If uElapse is less than USER_TIMER_MINIMUM, the timeout is set to USER_TIMER_MINIMUM If uElapse is greater than USER_TIMER_MAXIMUM, the timeout is set to USER_TIMER_MAXIMUM..
lptimerfunc
[In] Pointer to the function to be notified when the time-out value elapses For more information about the function, see tabindex = "0" keywords = "_ win32_TimerProc_cpp" xmlns:. Mshelp = "http://msdn.microsoft.com / mshelp> TimerProc. if
Lptimerfunc is null, the system posts a Tabindex = "0" keywords = "_ win32_wm_timer_cpp" xmlns: mshelp = "http://msdn.microsoft.com/mshelp">
WM_TIMER Message to the Application Queue. The Application Queue.
HWnd Member of the Message's TabINDEX = "0" keywords = "_ win32_msg_str_cpp" xmlns: mshelp = "http://msdn.microsoft.com/mshelp">
MSG Structure Contains the Value of The
Hwnd parameter.
// If this parameter is null, then the system will send
WM_TIMER to message queue,
The HWND in the MSG structure will contain hwnd parameters. If the parameter is not null, then the TimerProc. Function will be called when the time arrives.
Return Value
If the function succeeds and the hWnd parameter is NULL, the return value is an integer identifying the new timer An application can pass this value to the tabindex = "0" keywords = "_ win32_KillTimer_cpp" xmlns:. Mshelp = "http: // msdn .microsoft.com / mshelp "> Killtimer Function to Destroy The Timer.
// When the parameter hWnd is NULL and the function is running successfully, returns an integer to indicate the new Timer. The application calls the KillTimer function to destroy this Timer through this value.
IF Parameter Is Not Null, THE RETURN VALUE IS A NONZERO INTEGER. An Application Can Pass The value of the killtimer parameter to the killtimer function to designroy the timer.
// Conversely, the return value is a non-collar integer. The application can call the function to call the KillTimer destroy Timer through the KillTimer value.
If the function fails to create a timer, the return value is zero To get extended error information, call tabindex = "0" keywords = "_ win32_GetLastError" xmlns:. Mshelp = "http://msdn.microsoft.com/mshelp"> The getLastError. / / function failed, the return value is the lead, to get more error messages to see GetLastError.
Remarks
An application can process WM_TIMER messages by including a WM_TIMER case statement in the window procedure or by specifying a TimerProc callback function when creating the timer. When you specify a TimerProc callback function, the default window procedure calls the callback function when it processes WM_TIMER. Therefore .
The WParam Parameter of the WM_Timer Message Contains The Value of The Nidevent Parameter.
The Timer Identifier, NidEvent, IS Specific To The Associated Window. Another WINDOW CAN HAVE ITS OWN TIMER Which Has The Same Identifier As a Timer Owned by Another WINDOW. The Timers Are DISTINCT.
Settimer CAN Reuse Timer IDs in the case where hwnd is null.