精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>C/C++>>一般性编程问题>>Windows消息:鼠标、键盘等>>如何用settimer设置触发器

主题:如何用settimer设置触发器
发信人: liuzijie()
整理人: wenbobo(2002-12-06 22:40:21), 站内信件

--
※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.106.239.140]
发信人: tengel (Dragon), 信区: CLanguage
标  题: Re: 如何用SetTimer()设置触发器?希望能给出具体详细的使用办法!预谢!
发信站: 网易虚拟社区 (Mon Sep 20 16:39:58 1999), 站内信件

【 在 liuzijie (文刀) 的大作中提到: 】

SetTimer
The SetTimer function creates a timer with the specified time-out valu
e. 

UINT SetTimer(
  HWND hWnd,              // 窗口句柄
  UINT nIDEvent,          // 计时器标识
  UINT uElapse,           // 触发间隔时间
  TIMERPROC lpTimerFunc   // 处理过程地址
);
 
Parameters
hWnd 
Handle to the window to be associated with the timer. This window must
 be owned by the calling thread. If this parameter is NULL, no window 
is associated with the timer and the nIDEvent parameter is ignored. 
nIDEvent 
Specifies a nonzero timer identifier. If the hWnd parameter is NULL, t
his parameter is ignored. 
uElapse 
Specifies the time-out value, in milliseconds. 
lpTimerFunc 
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 app
lication queue. The hwnd member of the message'sMSG structure contains
 the value of the hWnd parameter. 

Return Values
If the function succeeds, the return value is an integer identifying t
he new timer. An application can pass this value, or the string identi
fier, if it exists, 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 c
ase statement in the window procedure or by specifying a TimerProc cal
lback function when creating the timer. When you specify a TimerProc c
allback function, the default window procedure calls the callback func
tion when it processes WM_TIMER. Therefore, you need to dispatch messa
ges in the calling thread, even when you use TimerProc instead of proc
essing WM_TIMER. 

The wParam parameter of the WM_TIMER message contains the value of the
 nIDEvent parameter. 


--
                                           _
   O           @___       G               : \  
  /|__       /|/         /\|\             :  \
 /|/_       / /\         \ X_             :   \
  /  |     __/  \          | \      0     :    \
 /    0        0|          /              :     \

※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.104.33.108]
发信人: liuzijie (文刀), 信区: CLanguage
标  题: Re: 如何用SetTimer()设置触发器?希望能给出具体详细的使用办法!预谢!
发信站: 网易虚拟社区 (Mon Sep 20 17:02:32 1999), 站内信件

【 在 liuzijie (文刀) 的大作中提到: 】


要使程序定期(比如过30秒)执行某一固定流程,我先是用SLEEP函数,可是
窗口就不在响应其他操作了。不知能否用SETTIMER实现这一功能,或是有什么
别的方法,请指教。
也可发E-MAIL,[email protected]
或哪位高手留个E。
预谢!!

--
※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 210.78.135.214]
发信人: dunhill (烟灰飞扬), 信区: CLanguage
标  题: Re: 如何用SetTimer()设置触发器?希望能给出具体详细的使用办法!预谢!
发信站: 网易虚拟社区 (Mon Sep 20 17:51:51 1999), 站内信件

: 要使程序定期(比如过30秒)执行某一固定流程,我先是用SLEEP函数,可是 
: 窗口就不在响应其他操作了。不知能否用SETTIMER实现这一功能,或是有什么 
: 别的方法,请指教。 

当然可以。你要抓WM_TIMER消息。
再仔细看看帮助吧。

--
烟水寻常事,荒村一钓徒。
深宵沉醉起,无处觅菰蒲。

※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 210.75.46.91]
发信人: tengel (Dragon), 信区: CLanguage
标  题: Re: 如何用SetTimer()设置触发器?希望能给出具体详细的使用办法!预谢!
发信站: 网易虚拟社区 (Tue Sep 21 09:30:34 1999), 站内信件

【 在 liuzijie (文刀) 的大作中提到: 】
: 【 在 liuzijie (文刀) 的大作中提到: 】


: 要使程序定期(比如过30秒)执行某一固定流程,我先是用SLEEP函数,可是
:    .......

也可以在用另外一个线程,单独处理和时间有关的操作

--
                                           _
   O           @___       G               : \  
  /|__       /|/         /\|\             :  \
 /|/_       / /\         \ X_             :   \
  /  |     __/  \          | \      0     :    \
 /    0        0|          /              :     \

※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.104.33.108]

[关闭][返回]