For WM_PAINT
the windowing code in DefWndProc
just sets a flag and then checks that flag only if the queue is empty the next time GetMessage
is called. Some mouse messages are also coalesced (older ones are removed when the newer ones arrive).
The real answer depends on the behaviour you're actually wanting to achieve.
If you are trying to avoid reentrancy just check a flag for a quick exit, something like:
////bool processing = false; // class/window instance variable
...
void HandleCustomMessage()
{
////if (processing)
////{
//// return;
////}
////processing = true;
DoSomething();
////processing = false;
}
If you want an actual priority queue, there are numerous PQ implementations. Add the data item to the PQ and then post a custom message (always the same ID). The custom message handler then asks the PQ for the highest priority item.
Another option is to intercept the
GetMessage
loop, use a call to
PeekMessage
to see if there is anything to do, then call
GetMessage
if a message is available, or check your PQ otherwise. You don't need a custom message with this approach.