Compartir a través de


Sending Messages (Windows CE 5.0)

Send Feedback

To send messages to a window, call the SendMessage function. Unlike the PostMessage function, SendMessage is a synchronous function. It does not return until the window procedure of the receiving window has processed the message.

Typically, you send a message when you want a window procedure to perform a task immediately. SendMessage sends the message directly to the window procedure of the receiving window. SendMessage waits until the window procedure completes processing and then returns the message result. Parent and child windows often communicate by sending messages to each other. For example, a parent window that has an edit control as its child window can set the text of the control by sending a message to it. The control can notify the parent window of user-initiated changes to the text by sending messages back to the parent window.

If the receiving thread is the same as the sending thread, SendMessage calls the window procedure directly. If the receiving thread is a different thread from the sending thread, the two message queues synchronize the passing of the message. The sending thread does not continue executing until the receiving thread processes the message. The receiving thread does not process the message if it is not executing a message loop. Consequently, if you send a message to a window in a thread that is not executing a message loop, the sending thread stops responding.

DWORD dwRetVal = SendMessage(MyWindow, WM_COMMAND, MyWParam, MyLParam);

See Also

Working with Windows and Messages | GWES Application Development

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.