The classic Win32 message loop looks something like this:
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
There is also a function PeekMessage()that checks if a message is available. In this case, you can change the message loop as:
while (GetMessage(&msg, NULL, 0, 0)) {
do {
TranslateMessage(&msg);
DispatchMessage(&msg);
} while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE));
onIdle();
}
The aforementioned loop will cause the translation / sending as long as there are still messages available for processing, and then when they are no more, it will call onIdle(). Then it returns to the outer loop to call again GetMessage(), to wait for the next message.
, onIdle Win32. , .NET.