UINT SetTimer( UINT nIDEvent, UINT nElapse, void (CALLBACK EXPORT* lpfnTimer)(HWND, UINT, UINT, DWORD) );
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.看不太懂,请帮我用汉语说说,不是直接翻译。说清这三个变量什么意思,该怎么赋值就行了。谢谢 

解决方案 »

  1.   

    nIDEventSpecifies 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.
    回调函数。指定处理WM_TIMER消息的回调函数的地址。如果这个参数为NULL,WM_TIMER消息被发送到应用程序消息队列中然后被CWnd对象处理。调用SetTimer(1, 1000, NULL); // SetTimer,1秒钟响应一次
    void CXX::OnTimer(UINT nID)
    {
     if(nID == 1)
     {
      ...
     }
     CXX::OnTimer(nID);
    }
      

  2.   

    第一个是定时器ID,用来标识定时器的,一般用1,2之类的就行了。第二个是定时器的时间间隔,单位是毫秒,第三个是回调函数,如果你不想用回调函数的话,设为NULL也行。
      

  3.   

    第一参数: 是事件,比如你要设置10个不同的计时器,就要分别编号
    第二参数: 是时间,以毫秒为单位。
    第三参数: 一时半会说不清楚,一般设为NULL就可以了举例:定义两个计时器,一个1秒种轮回一次,另一个3秒种轮回一次SetTimer(1,1000,NULL);//这是事件1,1秒钟的
    SetTimer(2,3000,NULL);//这是事件1,3秒钟的在时间的响应函数据里就可以这样
    void CXXXXX::OnTimer(UINT nIDEvent) 
    {
         if(nIDEvent==1)
         {
            //这里的代码1秒执行一次
         }
         else if(nIDEvent==2)
         {
           //这里的代码3秒执行一次
         }
    }