An application can use the WinSendMsg function to send a message directly to a window. An application uses this function to send messages to child windows. For example, the following code fragment sends an LM_INSERTITEM message to direct a list-box control to add an item to the end of its list:

    HWND hwndListBox;
    static CHAR szWeekday[] = "Tuesday";

    WinSendMsg(hwndListBox,
               LM_INSERTITEM,
               (MPARAM)LIT_END,
               MPFROMP(szWeekday));

WinSendMsg calls the window's window procedure and waits for it to handle the message and return a result. An application can send a message to any window in the system, as long as the application has the handle of the target window. The message queue does not store the message; however, the thread making the call must have a message queue.


[Back] [Next]