An application can set the owner for a window by using the WinSetOwner function. Typically, after setting the owner, a window notifies the owner window of the new relationship by sending it a message.

The code fragment in the following figure shows how to set the owner window and send it a message:

    #define NEW_OWNER 1

    HWND hwndMyWindow;
    HWND hwndNewOwner;

    if (WinSetOwner(hwndMyWindow, hwndNewOwner))

        /* Send a notification message.                                 */
        WinSendMsg(hwndNewOwner,   /* Sends to owner                    */
            WM_CONTROL,            /* Control message for notification  */
            (MPARAM) NEW_OWNER,    /* Notification code                 */
            NULL);                 /* No extra data                     */

A window can have only one owner, so WinSetOwner removes any previous owner.


[Back] [Next]