原文:
The
timeSetEvent function starts a specified timer event. The multimedia timer runs in its own thread. After the event is activated, it calls the specified callback function or sets or pulses the specified event object.
。
Parameters
uDelay
Event delay, in milliseconds. If this value is not in the range of the minimum and maximum event delays supported by the timer, the function returns an error.
uResolution
Resolution of the timer event, in milliseconds. The resolution increases with smaller values; a resolution of 0 indicates periodic events should occur with the greatest possible accuracy. To reduce system overhead, however, you should use the maximum value appropriate for your application.
lpTimeProc
Address of a callback function that is called once upon expiration of a single event or periodically upon expiration of periodic events. If
fuEvent specifies the TIME_CALLBACK_EVENT_SET or TIME_CALLBACK_EVENT_PULSE flag, then the
lpTimeProc parameter is interpreted as a handle to an event object. The event will be set or pulsed upon completion of a single event or periodically upon completion of periodic events.
dwUser
User-supplied callback data.
fuEvent
Timer event type. This parameter may include one of the following values.
Value
|
Meaning
|
TIME_ONESHOT
|
Event occurs once, after
uDelay milliseconds.
|
TIME_PERIODIC
|
Event occurs every
uDelay milliseconds.
|
The
fuEvent parameter may also include one of the following values:
Value
|
Meaning
|
TIME_CALLBACK_FUNCTION
|
When the timer expires, Windows calls the function pointed to by the
lpTimeProc parameter. This is the default.
|
TIME_CALLBACK_EVENT_SET
|
When the timer expires, Windows calls the
SetEvent function to set the event pointed to by the
lpTimeProc parameter. The
dwUser parameter is ignored.
|
TIME_CALLBACK_EVENT_PULSE
|
When the timer expires, Windows calls the
PulseEvent function to pulse the event pointed to by the
lpTimeProc parameter. The
dwUser parameter is ignored.
|
Return Values
Returns an identifier for the timer event if successful or an error otherwise. This function returns NULL if it fails and the timer event was not created. (This identifier is also passed to the callback function.)
Remarks
Each call to
timeSetEvent for periodic timer events requires a corresponding call to the
timeKillEvent function.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in mmsystem.h.
Import Library: Use winmm.lib.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in mmsystem.h.
Import Library: Use winmm.lib.
See Also
翻译:
TimerSetEvent启动一个指定的定时器事件,多媒体定时器运行在它自己的线程中。事件被激活之后,它调用指定的回调函数,(set orpulses)指定的时间对象。
MMRESULT timeSetEvent(
UINT
uDelay
,
UINT
uResolution
,
LPTIMECALLBACK
lpTimeProc
,
DWORD
dwUser
,
UINT
fuEvent
);
参数:
uDelay:事件的延时,微妙计,如果该值超出定时器支持的最大最小的延时范围,程序返回一个错误。
uResolution:计时器事件的分辨率,微秒计。分辨率随值的减小而增加。为零时意味着周期事件以最大的精确度发生。为了降低系统的开销,应用程序应选择能满足要求的最大值。
LpTimeProc:回调函数的地址,当单一事件期满或周期事件到达一个周期。如果fuEvent指定了TIME_CALLBACK_SET或TIME_CALLBACK_EVENT_PULSE标记,lpTimeProc被当作一个事件对象的指针,the event will be set or pulsed upon completion of a single enent or periodically upon completion of periodic events.
dwUser:用户提供的回调数据。
fuEvent:定时器类型,参数可能包含下列值之一。
Value
|
Meaning
|
TIME_ONESHOT
One shot
|
时间发生,一旦经过uDelay毫秒时间.
|
TIME_PERIODIC
periodic
|
每过
uDelay 毫秒事件发生一次
|
也可能是下面的值:
Value
|
Meaning
|
TIME_CALLBACK_FUNCTION
Call back function
|
当计时期满,窗口调用lpTimeProc参数指定的函数,为默认值。
|
TIME_CALLBACK_EVENT_SET
Call back event set
|
当计时器到期,窗口调用SetEvent函数,通过lpTimeProc参数设置事件指向,( to set the event pointed to by the lpTimeProc parameter),dwUser参数被忽略。
|
TIME_CALLBACK_EVENT_PULSE
Callback event pulse
|
|
返回值:如果调用成功或是其他错误时,为计时器事件返回一个标识符,如果失败或计时器事件为创建,返回值为零,该值也发送给回调函数。
备注:为周期事件调用timeSetEvent函数时要求相应的调用timeKillEvent函数。