I change my code with this code and no error or TRACEs happen!!!
Although the timer after a will (hours) stopped !
VOID CALLBACK CManager::TimerProc(HWND hwnd, UINT uMsg, UINT uIDEvent, DWORD dwTime)
{
CManager* pthread = (CManager*)AfxGetThread();
if (pthread)
{
if (::KillTimer(NULL,pthread->m_iIDTimer) != 0)
{
pthread->TimerFunc(pthread->m_iIDTimer);
pthread->m_iIDTimer = ::SetTimer(NULL,IDT_REFRESH,TIMER_DEWILL_TIME,TimerProc);
if (pthread->m_iIDTimer == 0)
{
TRACE("SetTimer failed"NL);
DWORD dErr = GetLastError();
}
}
else
{
TRACE("killTimer failed"NL);
DWORD dErr = GetLastError();
}
}
}
void CManager::TimerFunc(UINT uIDEvent)
{
if (m_iIDTimer != uIDEvent)
{
TRACE("-----------Error on CManager");
}
TRACE(">CManager::TimerFunc %i"NL, uIDEvent);
}
// ----------------------------------
For more information see [MSDN help about SetTimer] below:
SetTimer
The SetTimer function creates a timer with the specified time-out value.
UINT SetTimer(
HWND hWnd, // handle of window for timer messages
UINT nIDEvent, // timer identifier
UINT uElapse, // time-out value
TIMERPROC lpTimerFunc // address of timer procedure
);
Parameters
hWnd
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.
nIDEvent
Specifies a nonzero timer identifier. If the hWnd parameter is NULL, this parameter is ignored.
uElapse
Specifies the time-out value, in milliseconds.
lpTimerFunc
Pointer to the function to be notified when the time-out value elapses.