Jackiesteed

www.github.com/jackiesteed

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Desktop Window:

When you start the system, it automatically creates the desktop window. The desktop window is a system-defined window that paints the background of the screen and serves as the base for all windows displayed by all applications. Window manger maintains a windows list, at the head of which is the desktop window.

Parent Window and Owner Window:

A window can be created as a child window (WS_CHILD set) or a top-level window (WS_CHILD not set). A child window has a parent, which you specify when you call CreateWindowEx by specifying the hWndParent parameter and which you can change by calling SetParent. Those windows who have common parent are called sibling windows. A top-level window, on the other hand, has no parent. Its parent is NULL.

Ownership is a concept that uniquely relates to top-level windows. A top-level window can optionally have an owner, which is also specified when you call CreateWindowEx (also set hWndParent), and which you can change by a complicated mechanism. An application can use the GetWindow function with the GW_OWNER flag to retrieve a handle to a window's owner.

A window can have a parent, or it can have an owner, or it can have neither (set hWndParent as NULL), but it can never have both.

What would it mean for a window to have both a parent and an owner? Well, in order to have a parent, the window must itself be a child. But in order to have an owner, the window must be top-level. And top-level windows and child windows are mutually exclusive (and collectively exhaustive), because you either have the WS_CHILD style (which makes you a child) or you don't (which makes you top-level).

Then how do the parenthood and ownership take effect?

For owned windows:

  1)An owned window is always above its owner in the z-order, whereas not limit to its owner’s client area.

  2)When its owner is minimized, it should be hidden.

  3)The system automatically destroys an owned window when its owner is destroyed.

  4)Hiding the owner doesn’t affect the visibility of those to-be-owned ones.

For child windows:

  1) It is located based on its parent window, and can only be displayed within the client area of its parent window, moving along with its parent.

  2) When the parent is hidden, its children windows are also hidden.

  3) Once the parent is destroyed, the children windows are also destroyed.

Then why do Windows maintain two kinds of relationship?

To achieve more flexibility in managing windows. Just like the relationship between listbox and combobox, listbox may cover more area than its owner, but should be destroyed following tis owner .

-------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------

These lines are mostly quoted or translated from other passages, just to clarify some concept about window relationships.

It may be updated, to add some new points, and be requested for comment, since I haven't figured out how check the validity of some statements in the passage~ 

See more about this on msdn.

 

 

posted on 2012-05-12 22:08  Jackiesteed  阅读(231)  评论(0编辑  收藏  举报