Home > DeveloperSection > Interviews > What is the use of SendMessage() and PostMessage() and difference between them ?

Posted on    July-23-2011 7:42 AM

 Visual C++ Visual C++ 
Ratings:
 1 Answer(s)
  2270  View(s)
Rate this:

James Smith

Total Post:79

Points:395
Posted on    July-23-2011 12:00 AM

These are the Win32 API's provided to send a message to window Or a way to notify a window to perform some action.

SendMessage() - This message is sent directly to the window. It means it doesn't return until, the "sent message" is not processed( Message handler is not executed).

PostMessage() - This message is sent to the application message queue, from where application will pick up the message later on, gets processed. This API returns immediately as soon as it posts the message to message queue. It never waits for the respective message handler to be executed.

Don't want to miss updates? Please click the below button!

Follow MindStick