Holy cow, I wrote a book!
As we well know,
the window manager
generates various messages on-demand
rather than posting them into the queue at the time the
But what happens if you manually post one of these messages,
PostMessage(hwnd, WM_PAINT, 0, 0)?
Does that clear the internal flag that says "This window needs
a paint message?"
PostMessage(hwnd, WM_PAINT, 0, 0)
The window manager
does not have a
prank call detector.
If you post a fake
then a fake
shows up in the message queue.
The part of the window manager which manages the
"Does this window need to be repainted?"
does not wiretap every telephone call
to see if somebody is prank-calling a window with
the WM_PAINT message,
and then say,
"You know what?
I'm going to make that prank call a reality and
make it act like a real WM_PAINT message."
Imagine if the act of prank-calling somebody
caused Prince Albert to stop by for a visit!
In particular, the posted message goes into the posted message
queue and will rise to the front of the queue as messages
On the other hand, the auto-generated message will remain
in its proto-message state until the queue is finally empty.
It then follows as a consequence that if you post one of these
like WM_TIMER message,
you don't get any magical coalescing behavior because the coalescing
happens as part of the auto-generation,
not as part of the PostMessage.
These prank-call messages also appear in the message queue in posted order
rather than being generated at low priority like normal auto-generated