注册 登录
编程论坛 VC++/MFC

关于C++中SetTimer()的问题

tlby 发布于 2011-10-23 14:51, 2536 次点击
UINT SetTimer(
  HWND hWnd,
  UINT nIDEvent,
  UINT uElapse,
  TIMERPROC lpTimerFunc
);
第二个参数也就是定时器的ID,是自己随便定的吗?只要不重复就行吗?
他触发时是触发整个程序嘛?菜鸟刚学,望多多指教~!
5 回复
#2
naruto012011-10-23 15:19
MSDN Library
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.
#3
tlby2011-10-23 15:25
回复 2楼 naruto01
看不大懂呀!你看我这样可以不?
SetTimer(hwnd,1,500,NULL);
#4
naruto012011-10-23 15:33
只要非零值,就好了。
表示设定一个与hwnd关联的Timer, 这个Timer的标识是1, 触发时间是0.5s, time-out时在消息队列里放入一个WM_TIMER消息
我也是刚学,如果理解有错,概不负责啊
#5
gball2011-10-23 16:01
提示: 作者被禁止或删除 内容自动屏蔽,只有管理员可见
#6
gball2011-10-23 16:40
提示: 作者被禁止或删除 内容自动屏蔽,只有管理员可见
1