网站首页  词典首页

请输入您要查询的函数:

 

术语 settimer
释义 SetTimer
语法:
UINT_PTR SetTimer( HWND hWnd,
UINT_PTR nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc
);
SetTimer函数
SetTimer函数创建一个指定的时间计时器超时值。
参数
hWnd
[in]的窗口的句柄,必须与计时器。该窗口必须拥有调用线程。如果一个hWnd NULL值是通过与一个现有计时器nIDEvent,该计时器将在相同的方式,现有的非空hWnd计时器将被替换。
nIDEvent
[in]指定一个非零的计时器标识符。如果hWnd参数为NULL,并且nIDEvent不匹配现有的计时器便被忽略,一个新的计时器的ID生成。如果hWnd参数不为NULL和hWnd指定的窗口已经与价值nIDEvent定时器,那么现有的计时器是由新的计时器取代。当SetTimer取代一个计时器,计时器被重置。因此,一条消息将被发送后,目前的超时值经过的,但先前设定的超时值被忽略。如果呼叫并不是要取代现有的计时器,nIDEvent应该是0,如果hWnd是空。
uElapse
[in]指定超时值,以毫秒为单位。
Windows NT:如果uElapse比USER_TIMER_MAXIMUM更大,超时设置为1。
视窗2000/XP的:如果uElapse比USER_TIMER_MINIMUM少,超时设置为USER_TIMER_MINIMUM。
Windows Server 2003的:如果uElapse比USER_TIMER_MAXIMUM更大,超时设置为USER_TIMER_MAXIMUM。
Windows XP的SP2/Windows Server 2003 SP1的:如果uElapse比USER_TIMER_MINIMUM少,超时设置为USER_TIMER_MINIMUM。如果uElapse比USER_TIMER_MAXIMUM更大,超时设置为USER_TIMER_MAXIMUM。
lpTimerFunc
[in]指向函数的通知时,超时值经过的。如需有关函数的详细信息,请参阅TimerProc。如果lpTimerFunc为NULL,则系统岗位WM_TIMER消息到应用程序队列。该消息的MSG结构hWnd成员包含hWnd参数值。
返回值
如果函数成功的hWnd参数为NULL,则返回值是一个整数,确定新的计时器。应用程序可以通过这个值KillTimer函数销毁计时器。
如果函数成功的hWnd参数不是NULL,则返回值为非零整数。应用程序可以通过该nIDEvent参数值KillTimer函数销毁计时器。
如果函数失败创建一个计时器,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
应用程序可以处理,包括在窗口过程中WM_TIMER案件陈述或指定TimerProc回调函数在创建计时器WM_TIMER消息。当您指定一个TimerProc回调函数,默认的窗口过程调用回调函数时,它处理中WM_TIMER。因此,您需要派遣调用线程的消息,即使您使用TimerProc不是处理中WM_TIMER。
的WM_TIMER消息wParam参数包含nIDEvent参数的值。
计时器的标识,nIDEvent,是具体到相关窗口。另一个窗口可以有自己独立的定时器它有另一个窗口所拥有的计时器相同的标识符。该定时器是不同的。
SetTimer可以重复使用的计时器ID的情况下hWnd是空。
例如
有关示例,请参见创建一个计时器。
功能信息
最低DLL版本 user32.dll
在Winuser.h中HeaderDeclared,头文件:winuser.h
import libraryUser32.lib
最低操作系统Windows 95,Windows NT 3.1
UnicodeImplemented为Unicode版本。
参见
定时器概述,KillTimer,味精,TimerProc,中WM_TIMER
==英文原文==SetTimer Function
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 SetTimer replaces a timer, the timer is reset. Therefore, a message will be sent after the current time-out value elapses, but the previously set time-out value is ignored. If the call is not intended to replace an existing 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 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.
Example
For an example, see Creating a Timer .
Function Information
Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systemsWindows 95, Windows NT 3.1
UnicodeImplemented as Unicode version.
See Also
Timers Overview , KillTimer , MSG , TimerProc , WM_TIMER
==原始网址==http://msdn.microsoft.com/en-us/library/ms644906(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:23:59