A parent or owner window can retrieve the handle of a child or owned window by using the WinWindowFromID function and supplying the identifier of the child or owned window. WinWindowFromID searches all child and owned windows to locate the window with the given identifier. The window identifier is set when the application creates the child or owned window.

Typically, an owned window uses WinQueryWindow to get the handle of the owner window; then uses WinSendMsg to issue a notification message to its owner window.

The code fragment in the following figure retrieves the window handle of an owner window and sends the window a WM_ENABLE message.

    HWND hwndOwned;
    HWND hwndOwner;

    case WM_CONTROL:
        switch (SHORT2FROMMP (mp2)) {
            case BN_CLICKED:
                hwndOwned = WinWindowFromID(hwndOwner,
                (ULONG)SHORT1FROMMP(mp1));
                WinSendMsg(hwndOwned, WM_ENABLE,
                (MPARAM)TRUE, (MPARAM) NULL);
                return 0;
            .
            . /* Check for other notification codes. */
            .

            }

An application also can retrieve the handle of a child window by using the WinWindowFromPoint function and supplying a point in the corresponding parent window.


[Back] [Next]