次の方法で共有


Sending Messages (Windows Embedded CE 6.0)

1/6/2010

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

Concepts

Working with Windows and Messages

Other Resources

GWES Application Development