用Settimer()函数设置一个时钟,
用Ontimer()函数执行你自己的任务:)
具体用法查MSDN!

解决方案 »

  1.   

    用这个就行了 :
    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.
      

  2.   

    SetTimer(1000); 为何系统报错?
      

  3.   

    不好意思
    SetTimer(1,1000,NULL);
      

  4.   

    SetTime带三个参,第一个是计时器的ID,一个程序可以有几个计时器,指定不同的ID就是了,第二个是WM_TIMER事件产生的间隔,以毫秒为单位,第三个是CALLBACK函数,一般用NULL就是了。
    然后用WM_TIMER()把WM_TIMER事件映射到OnTimer(UINT nID)函数上。
      

  5.   

    对了,用完后用KillTimer(nID)把Timer Kill掉。
    WM_TIMER事件发送最小间隔是55ms,所以把间隔设的太小是没用的。
    这种计时器的计时是不精确的。
    WM_TIMER事件优先级是很低的,不能通过计数WM_TIMER的次数来计时.