The various ways of sending a message

Raymond Chen

There are several variations on the SendMessage function, but some are special cases of others.

The simplest version is SendMessage itself, which sends a message and waits indefinitely for the response.

The next level up is SendMessageTimeout which sends a message and waits for the response or until a certain amount of time has elapsed. SendMessage is just SendMessageTimeout with an INFINITE timeout.

Another version of SendMessage is SendNotifyMessage, which is like SendMessage except that it doesn’t wait for the response. It returns immediately and ignores the result produced by the receiving window.

The last SendMessage-style functions is SendMessageCallback. This sends a message and then returns immediately. When the recipient finally returns a response, the callback is called.

SendNotifyMessage is SendMessageCallback with a callback that does nothing.

That’s how the four message-sending functions fit together.

Bonus remark: If you use any of the above send-type functions to send a message to a window that belongs to the sending thread, the call is made synchronously.


Discussion is closed.

Feedback usabilla icon