今天犯了一个粗心的错误,在无窗口线程中,SetTimer中设置计时器ID,而WM_TIMER消息响应函数中得到的计时器ID却不是之前设置的计时器ID.
// 111902.cpp : Defines .../n");
::SetTimer(NULL,1,1000,OnTimerProc);
MSG msg;
while (GetMessage(&msg, 0, 0, 0) >...UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
{
printf("OnTimerProc: %6d/n",idEvent);
}
对应计时器ID的输出的是一个随机数字...When SetTimer replaces a timer, the timer is reset....注:只有当hWnd参数为非空时,计时器的ID为设置的 nIDEvent, 系统为你自动生成一个计时器ID,可由返回时值获取.