Question

I'm aware that some messages types are sent directly to window procedures, while others are posted to a thread's message queue, but I haven't found any way to determine if a message will be sent or posted.

MSDN is half-helpful; it explained what's going on but the examples it gives are presumably not exhaustive.

Is there a definitive list of sent vs. posted messages, or a way to decide which type a message is?

Was it helpful?

Solution

And some messages are neither posted nor sent. Such is the case of WM_PAINT, WM_TIMER and a few others. They are simply returned by GetMessage when the queue of posted messages are empty.

I'm not sure what applications you are trying to hook, but if you have to ask such questions, then I/m a bit scared. Nothing is more frustrating for a developer to spend time over user-reported crashes only to find out that the cause is from some other application that is injecting misbehaving code. Tread carefully!

Also, Spy++ (tool that ships with Visual Studio) will show you which messages are posted/sent/recevied for any given live windows app.

OTHER TIPS

Use InSendMessage or InSendMessageEx to determine if you are processing a message that was sent by a call to the SendMessage function.

The MSDN pages documenting each message should be considered the authoritative source for this:

The WM_LBUTTONDOWN message is posted when ...

The WM_SETFOCUS message is sent to a window after ...

etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top