Home winapi Features SendMessage and PostMessage

Features SendMessage and PostMessage




What is the difference between the sendMessage and postmessage ?

Answer 1, Authority 100%

postmessage – sets a message in the queue, and the code is performed on.

SendMessage – SendMessage Function Stepted message immediately

Answer 2, Authority 250%

(refinement-comment to the answer @asen )

  • and postmessage and sendmessage if you use your terminology, “send a message immediately”, since the only one you can send Messages (with the exception of Nonqueued Messages ) is some inner queue .

  • it is implemented because otherwise the Race Conditions type 50 streams were sent at the same time made SendMessage would be very problematic.

  • Most importantly, What was needed to write about these functions – this is what SendMessage We are waiting for the message processing and returns the result and PostMessage just puts a message in the queue and completely does not care about What happens next.

  • The last fact, by the way, is noticeable from their signatures:

    bool winpi postmessage (hwnd hwnd, uint msg, WPARAM WPARAM, LPARAM LPARAM);
    Lresult Winpi SendMessage (Hwnd Hwnd, Uint MSG, WPARAM WPARAM, LPARAM LPARAM);

Answer 3, Authority 100%

SendMessage – Synchronous, PostMessage – asynchronous.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions