The SendMessage and PostMessage functions let applications pass messages to their windows or to the windows of other applications.
The PostMessage function directs Windows to post the message by placing it in the application queue. Control returns immediately to the calling application, and any action to be carried out as a result of the message does not occur until the message is read from the queue.
The SendMessage function directs Windows to send a message directly to the given window function, bypassing the application queue. Windows does not return control to the calling application until the window function that receives the message processes the message.
When an application transmits a message, it must send the message by calling SendMessage if the application relies on the return value of a message. The return value of SendMessage is the same as the return value of the function that processed the message. PostMessage returns immediately after sending the message, so its return value is only a Boolean value indicating whether the message was successfully sent and so does not indicate how the message was processed.
Windows communicates with applications through window messages. The messages are passed (sent or posted) to an application's window function to let the function process the messages as desired. Although an application's main function may read and dispatch window messages, in most cases only the window function processes them.