Owned Windows:窗口所有者

 Owned Windows

An overlapped or pop-up window can be owned by another overlapped or pop-up window. Being owned places several constraints on a window.

  • An owned window is always above its owner in the z-order.
  • The system automatically destroys an owned window when its owner is destroyed.
  • An owned window is hidden when its owner is minimized.

Only an overlapped or pop-up window can be an owner window; a child window cannot be an owner window. An application creates an owned window by specifying the owner's window handle as the hwndParent parameter of CreateWindowEx when it creates a window with the WS_OVERLAPPED or WS_POPUP style. The hwndParent parameter must identify an overlapped or pop-up window. If hwndParent identifies a child window, the system assigns ownership to the top-level parent window of the child window. After creating an owned window, an application cannot transfer ownership of the window to another window.

Dialog boxes and message boxes are owned windows by default. An application specifies the owner window when calling a function that creates a dialog box or message box.

An application can use the GetWindow function with the GW_OWNER flag to retrieve a handle to a window's owner.

根据上述介绍,可以看出一旦所有者创建自己拥有窗口后就不能更改所有者关系,要想改变就得重新创建。

但是有一个函数是SetOwner,可以设置这个关系,这是不是指在原先不拥有这种关系的窗口之间设置这种

关系?我觉得应当是。

Owner和Parent的关系不同,Owner关闭时要关闭所有自己所述的窗口,Parent不具有这个特点。

需要某个窗口一定要在某个窗口上时比较有用.

你可能感兴趣的:(windows,function,application,System,dialog,constraints)