June 14, 2011

Parent/Child versus Owner/Owned in Windows

In pure Windows terms.
Owner property of a window in .NET

In pure windows terms:
Child windows are rendered within the client area of their parent window (eg: buttons, text boxes, etc.).
A child window has the WS_CHILD style and is confined to the client area of its parent window. An application typically uses child windows to divide the client area of a parent window into functional areas. A child window can have it's parent window changed.

Owned windows are rendered outside the client area of their owner window (dialog boxes, message boxes, etc.)
An owned window is an overlapped or pop-up window (WS_OVERLAPPED or WS_POPUP style style) and are used for rendering outside of a owner window’s client area. Ownership of Owned windows cannot be transferred.
The Owner is responsible for for creating/destroying the owned window.

Do WM_COMMAND messages get sent to the owner window or parent window first? My work colleague strongly argues that the OS first tries to send them to the owner window but if this is not set (NULL[==the desktop window]) then the message is sent to the parent window. However, I can not find any documentation that collaborates this.

This link argues that a window can have eiether an Owner or a Parent but not both.

No comments: