You should use the return values of SetTimer() by storing them in member variables and pass these when killing the timer:
BOOL CFlashingProgressBar::OnInitDialog()
{
m_nEndTimer = SetTimer(EndDialogTimer,40*1000,NULL);
m_nCntTimer = SetTimer(CounterTimer,5*1000,NULL);
return TRUE;
}
void CFlashingProgressBar::KillTimers()
{
if (m_nEndTimer)
KillTimer(m_nEndTimer);
if (m_nCntTimer)
KillTimer(m_nCntTimer);
m_nEndTimer = m_nCntTimer = 0;
}
Also don't forget to kill the timers when the window is closed (e.g. in
OnClose()
).