I have encountered a, so it seems to me, strange behaviour of the WinAPI. In my program I am setting a timer for the window with
::SetTimer(window_handle, timer_id, 10, NULL);
and handle the WM_TIMER message in my window procedure. To reduce the amount of cpu time needed I am also using the ::WaitMessage
function in my message pump.
Turns out now that, as long as I have the ::WaitMessage
function there, the WM_TIMER messages just stop coming after a while. If I remove it from my message pump everything works just fine as expected.
Now I wonder wether I set up my timer wrong or if this is standard behaviour of ::WaitMessage
. Searching MSDN and the web did not give me an idea why this is like this.
Here is the message pump I use:
while(true) {
if(GetMessage(&msg, _window_handle, 0, 0) > 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
} else {
return 0;
}
WaitMessage();
}
Hope that someone can clear this up for me.