API函数之三 SetTimer Function
来源:互联网 发布:我国消防现状数据 编辑:程序博客网 时间:2024/06/07 01:19
The SetTimer function creates a timer with the specified time-out value.
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 must be owned by the calling thread. If a NULL value for hWnd is passed in along with an nIDEvent of an existing timer, that timer will be replaced in the same way that an existing non-NULL hWnd timer will be.
- nIDEvent
- [in] Specifies a nonzero timer identifier. If the hWnd parameter is NULL, and the nIDEvent does not match an existing timer then it is ignored and a new timer ID is generated. 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. When SetTimerreplaces a timer, the timer is reset. Therefore, a message will be sentafter the current time-out value elapses, but the previously settime-out value is ignored. If the call is not intended to replace anexisting timer, nIDEvent should be 0 if the hWnd is NULL.
- uElapse
- [in] Specifies the time-out value, in milliseconds.
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, the timeout is set to USER_TIMER_MINIMUM.
Windows Server 2003: If uElapse is greater than USER_TIMER_MAXIMUM, the 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 TimerProc. If lpTimerFunc is NULL, the system posts a WM_TIMER message to the application queue. The hwnd member of the message's MSG structure contains the value of the hWnd parameter.
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 KillTimer function to destroy the timer.
If the function succeeds and the hWnd parameter is not NULL, then the return value is a nonzero integer. An application can pass the value of the nIDEvent parameter to the KillTimer function to destroy the timer.
If the function fails to create a timer, the return value is zero. To get extended error information, call 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, you need to dispatch messages in the calling thread, even when you use TimerProc instead of processing WM_TIMER.
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 owntimer 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.
- API函数之三 SetTimer Function
- API函数之三 MessageBox Function
- Windows API - Timer Function , SetTimer和KillTimer函数
- SetTimer这个API函数
- SetTimer()函数的剖析(API)
- API函数之二 ShowWindow Function
- API函数之四 TerminateProcess Function
- API函数之五 OpenProcess Function
- SetTimer函数
- SetTimer函数....
- SetTimer()函数
- SetTimer函数
- Windows API一日一练(67)SetTimer和KillTimer函数
- Windows API一日一练(67)SetTimer和KillTimer函数
- Windows API一日一练(67)SetTimer和KillTimer函数
- Windows API一日一练(67)SetTimer和KillTimer函数
- Windows API一日一练(67)SetTimer和KillTimer函数
- Windows API一日一练(67)SetTimer和KillTimer函数
- asp企业建站系统 最新推出的 免费下载
- 我的新博客http://blog.csdn.net/ExSystem 本博客不再更新,谢谢!
- Difference between BW 3.5 and BI 7.0
- 原型基本搞定
- 【编程基础】程序的执行过程
- API函数之三 SetTimer Function
- Hibernate笔记1
- 关于JSP生成HTML汉字乱码问题
- Rationla Rose
- Autodesk官方最新的.NET教程(C#)
- 真正中文攻略之月は東に日は西に 东月西阳
- J2EE中web.xml的常用配置
- 关于学而时习之,不亦悦乎
- 字符串转十六进制,和Unicode