Posting Messages

Use the PostMessage function to post a message to a window. PostMessage combines the message identifier and parameters into a message and places it on the receiver's message queue. Eventually, the receiver's message loop removes the message from the message queue and dispatches it to the appropriate window procedure.

PostMessage is an asynchronous function. Windows CE does not synchronize between the sending thread and the receiving thread for posted messages. When the call to PostMessage returns, there is no guarantee that the window procedure for the receiver window has processed the message. In fact, if the message was posted to the same thread, the window procedure definitely has not processed the message.

You can post a message without specifying a window. If you supply a NULL window handle when you call the PostMessage function, the message is posted to the queue associated with the current thread. Because no window handle is specified, the application must process the message directly from the message loop. This is one way to create a message that applies to the entire application, instead of to a specific window.