用Settimer()函数设置一个时钟,
用Ontimer()函数执行你自己的任务:)
具体用法查MSDN!
解决方案 »
- windows服务无法启动,一直显示正在启动
- 对 ...路径访问被拒绝???
- CListCtrl中重写的函数MeasureItem不被调用
- 使用WMI,多开了3~4个线程?MSDN的例子错误?
- 把exe改成dll的问题
- 非modal模式CDlg类的创建显示
- (初学者)在做TCP/IP客户机和服务器时,各位高手都用的是哪些类,还是API,它们之间又有什么区别呢?
- 文档and模板,搞不懂,help me
- 如何使一个窗口在启动时默认成最大化
- 基于对话框的应用程序如何一启动就先把对话框隐藏掉?
- 在CTreeView中执行GetTreeCtrl().SetFont(GetTreeCtrl().GetFont())后的结果
- HELP!!!谁有通过域名查IP的资料或代码?
CWnd::SetTimer
UINT SetTimer( UINT nIDEvent, UINT nElapse, void (CALLBACK EXPORT* lpfnTimer)(HWND, UINT, UINT, DWORD) );Return ValueThe timer identifier of the new timer if the function is successful. An application passes this value to the KillTimer member function to kill the timer. Nonzero if successful; otherwise 0.ParametersnIDEventSpecifies a nonzero timer identifier.nElapseSpecifies the time-out value, in milliseconds.lpfnTimerSpecifies the address of the application-supplied TimerProc callback function that processes the WM_TIMER messages. If this parameter is NULL, the WM_TIMER messages are placed in the application’s message queue and handled by the CWnd object.
SetTimer(1,1000,NULL);
然后用WM_TIMER()把WM_TIMER事件映射到OnTimer(UINT nID)函数上。
WM_TIMER事件发送最小间隔是55ms,所以把间隔设的太小是没用的。
这种计时器的计时是不精确的。
WM_TIMER事件优先级是很低的,不能通过计数WM_TIMER的次数来计时.