An application can process WM_TIMER messages by including a WM_TIMER case statement in the window procedure or by specifying a TimerProc callback function when creating the timer. When you specify a TimerProc callback function, the default window procedure calls the callback function when it processes WM_TIMER. Therefore, you need to dispatch messages in the calling thread, even when you use TimerProc instead of processing WM_TIMER.
The wParam parameter of the WM_TIMER message contains the value of the nIDEvent parameter.
The timer identifier, nIDEvent, is specific to the associated window. Another window can have its own timer which has the same identifier as a timer owned by another window. The timers are distinct.
这里想说明一个问题, SetTimer(NULL, NULL, 2000, (TIMERPROC)TimerFunc);
TimerFunc是马上执行还是2000毫秒后再执行呢?
SetTimer 仅仅注册一个处理WM_TIMER的处理函数,所以2000后TimerFunc才被执行。
本文详细解析了Windows消息WM_TIMER的工作原理及SetTimer函数的使用方法,特别针对SetTimer注册处理函数的时机进行了深入探讨,帮助读者理解WM_TIMER消息处理机制。
2512

被折叠的 条评论
为什么被折叠?



