代码:
void CALLBACK SelMon_Timer(
HWND hwnd, 
UINT uMsg, 
UINT idEvent, 
DWORD dwTime )
{
if (ipDeath !=NULL)
{
if (*ipDeath == 0)
{
BeatMon();
return ;
}
}
SelMon();
}void CALLBACK BeatMon_Timer(
   HWND hwnd, 
   UINT uMsg, 
   UINT idEvent, 
DWORD dwTime )
{
BeatMon();
}
void CWGFram::OnStart() 
{
UpdateData( true);
int iTimer =m_iTime*1000;
int ibeatMon = iTimer-500;
iHP =m_iHp;

::SetTimer(NULL,Timer1,iTimer,SelMon_Timer);
::SetTimer(NULL,Timer2,ibeatMon,BeatMon_Timer);
}
void CWGFram::OnStop() 
{
::KillTimer(NULL,Timer1);
::KillTimer(NULL,Timer2);


}第二个定时器 kill不了 回调函数 还在定时调用啊晕  请高手帮忙分析下 这代码哪里错误了。。

解决方案 »

  1.   

    UINT_PTR SetTimer(
      HWND hWnd,              // handle to window
      UINT_PTR nIDEvent,      // timer identifier
      UINT uElapse,           // time-out value
      TIMERPROC lpTimerFunc   // timer procedure
    );hWnd 
    [in] 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
      

  2.   

    SetTimer定时器不指定窗口,实际的定时器ID不一定时你参数指定的ID
    这时KillTimer你应该用SetTimer返回的id
      

  3.   

    kill之后,消息队列里可能还有残留的WM_TIMER消息等待执行,不代表kill失败