Owner-Owned Windows

As previously mentioned, one window can own another. In such cases, the window that owns another window is called the owner window, and the window that is owned is called the owned window. Although the relationship between an owner window and an owned window is similar to the relationship between a parent and child window there are some differences. For example, unlike child windows, owned windows may draw outside of their owners.

You can create an owner-owned relationship between top-level windows when you create a window with the WS_POPUP style. Because top-level windows do not have parents, the window that you specify as the parent when you call the CreateWindow function becomes the owner of the new window. Owned windows may in turn own other windows. You can use the GetParent function to return the owner of a specified window. When a window is destroyed, any windows that it owns are also destroyed.

Owner-owned windows move as a group. If you move a window forward in the Z order, its owner window and owned windows move forward with it. Windows CE keeps owned windows in front of their owners. Although Windows CE does not prevent you from inserting a top-level window between an owner window and an owned window, it does keep owned groups of windows together when one is moved in the Z order. This means that when you change a window's Z order, Windows CE displaces any windows that are between the window and its owned or owner windows. Moving or sizing a window does not affect the location or size of its owner or owned windows.

You can create a WS_POPUP window with a NULL owner. When you do, the window becomes partially owned by the desktop. If Windows CE moves the desktop to the top of the Z order, these windows will remain on top of the desktop. However, if you move the window to the top of the Z order, it does not pull the desktop with it. Threads in the system that do not usually have any kind of window interface use this style when they need to display a message to the user.