user4129935
user4129935

Reputation:

Are WM_ERASEBKGND messages posted to the message queue?

WM_PAINT messages are not posted to the message queue, but rather when the message queue is empty, the WM_PAINT message is sent to the window procedure (if some area of the window is invalid).

However, are WM_ERASEBKGND messages sent in some similar way, or are they simply posted to the message queue (the documentation don't say anything about this).

Upvotes: 2

Views: 310

Answers (1)

Hans Passant
Hans Passant

Reputation: 942256

It is both, not untypical for Windows messages. It will be sent when the program executes a command like UpdateWindow() or processes a message like WM_SYSCOMMAND that moves or resizes the window. It will be posted when the program has called InvalidateRect().

Same is true for WM_PAINT, normally a "posted" message but only returned by GetMessage() when the message queue is empty. It however will be sent when you call UpdateWindow(), ensuring the window is painted when it returns.

Not taking a dependency on those implementation details is pretty important.

Upvotes: 4

Related Questions