When passing messages between windows using the WinPostMsg() or WinSendMsg() functions, the window handle of the destination window must be known and specified in the message. If window handles are not defined globally, the required handle must be obtained from Presentation Manager. This may be achieved in a number of ways:
The WinQueryWindow() call returns the handle of the required window. Relationships other than parent/child may also be used by this function; the valid relationships are described, along with the WinQueryWindow() function, in the IBM OS/2 Version 2.0 Presentation Manager Reference.
The WinWindowFromID() function also returns the handle of the required window.
The above example assumes that the application has been added to the OS/2
Window List using the WinAddSwitchEntry() function, and the handle
of its main frame window supplied as a parameter. See Figure
"WinAddSwitchEntry() Function".
When passing messages synchronously to control windows using the WinSendDlgItemMsg() function, it is generally assumed that the target control window is a child of the current window or dialog box. Thus the parent window handle is the handle of the current window, and the window identifier is also known to the current window procedure. An exception is the case where a window procedure wishes to send a message to a frame control of its own parent frame window. In this case a WinQueryWindow() call must be issued with the QW_PARENT parameter to determine the handle of the frame window. The WinSendDlgItemMsg() function may then be used with this handle and the window identifier of the required frame control.