当前位置:网站首页>Win32 child window parent window window owner
Win32 child window parent window window owner
2022-06-10 19:07:00 【Plug in development】
List of articles
stay windows In the system , Each window object has a corresponding data structure , To form a list Linked list . The window manager of the system uses this list To get window information and manage each window . There are four pieces of data in this data structure to build list, namely child、sibling、parent、owner Four domains .
1. Window relations
There are two kinds of relationships between windows :owner-owned Relationship and parent-child Relationship . The former is called having / Be owned by , The latter is called the father / Child relationship . In this article , call owner The window is the owner window . let me put it another way , A window has a parent window (parent) At the same time , It may also be owned by different windows (owner), You can also have your own sub window (child). stay MFC Of CWnd Class , The owner window is saved in m_hWndOwner In the member variable , The parent window is saved in m_hParent in , However, these two values do not necessarily correspond to the values in the window object data structure .
If a window data owner Domain non NULL, Then it and the window establish owner-owned Relationship , Ownership determines :
(1) The owned window is always displayed in front of the window that owns it ;
(2) When the owner window is minimized , All the windows it has will be hidden ;
(3) When the owner window is destroyed , All the windows it has will be destroyed .
It should be noted that , Hiding the owner window does not affect the visibility of the windows it owns . such as : If the window A Have a window B, window B Have a window C, When the window A When minimized , window B Be hidden , But the window C Still visible .
If a window parent Domain non NULL, Between it and the window parent-child Relationship . A parent-child relationship has the following characteristics :
(1) The display position of the window on the screen . The parent window provides the coordinate system used to locate the child window , A child window can only be displayed in the client area of its parent window , The rest will be cut . This pruning rule determines if the parent window is not visible , The child window must not be visible . If the parent window is moved outside the screen , The same goes for child windows .
(2) When the parent window is hidden , All its child windows are also hidden .
(3) When the parent window is destroyed , All child windows it has will be destroyed .
Be careful ! Minimizing the parent window does not affect the visibility of the child window , The child window is minimized with the parent window , But it's WS_VISIBLE Properties do not change .
2. Description and limitations of window types
(1) Console window (desktop window). This is the earliest window created by the system . You can think of it as all WS_OVERLAPPED Type window owner and parent window .
(2)WS_OVERLAPPED Type of window can be displayed anywhere on the screen . Their owner window is the console . When the system shuts down When , It will destroy all overlapped Type of window .
(3)WS_POPUP Type of window can be displayed anywhere on the screen , They usually have no parent window , But if you explicitly call SetParent, This type of window can also have a parent window . WS_POPUP The owner of a window of type is in CreateWindow Function by setting hWndParent Parameter given , If hWndParent Not a sub window , Then the window will become the... Of the new pop-up window owner, otherwise , System from hWndParent Look up in the parent window of , Until you find the first non child window , Make it the of the pop-up window owner. When owner When the window is destroyed , The system automatically destroys this pop-up window .
(4) The owner window (owner) Can only be overlapped perhaps pop-up Type of window , A child window cannot be an owner window , That is, child windows cannot have other windows .overlapped perhaps pop-up Windows of type have other windows at the same time , Can also be owned . In the use of CreateWindowEx establish WS_OVERLAPPED perhaps WS_POPUP Type window , Can be in hwndParent Parameter gives a handle to its owner window . If hwndParent What's given is a child Window handle of type , The system will automatically transfer the ownership of the newly created window to the top-level parent window of the child window . under these circumstances , Parameters hwndParent Saved in the new window parent domain , Its owner window handle is stored in owner domain .
(5) By default , Dialog boxes and message boxes belong to owned window , Unless they are explicitly given when they are created WS_CHILD attribute ,( For example, the dialog box is embedded in the dialog box ) Otherwise, the system is responsible for assigning owner window . It should be noted that , Once created owned Type of window , Can no longer change all their relationships , because WIN32 There is no way to change the window owner . And in Win32 in , Due to the existence of multithreading , So pay attention to ensure that the parent-child window or owner/owned Windows must belong to the same thread .
(6) about WS_CHILD Type of window , Its parent window is its owner window . The parent window of a child window is also in CreateWindow Function hWndParent Parameter specified . A child window can only be displayed in the client area of the parent window , And destroy it with the parent window .
3. Description of several related functions
GetWindow(hWnd, GW_OWNER) Always return to the owner of the window (owner).
about SetParent,msdn It explains that the parent-child window must be in the same process . But because the window handle is globally unique in the system , Not belonging to the same process , You can also successfully call , But the consequences are unknown .GetParent The return value of is complex , about overlapped Type of window , It returns 0, about WS_CHILD type , It returns to its parent window , about WS_POPUP type , It returns to its owner window , If you want to get the one you passed in when you created it hwndParent Parameters , Should use the GetWindowWord(GWW_HWNDPARENT) function .
GetWindowWord(hWnd, GWW_HWNDPARENT) Returns the parent window of a window , without , Return its owner .
4. Author Q & A
If you have any questions , Please leave a message .
边栏推荐
- Opencv does not rely on any third-party database for face detection
- [kuangbin]专题二十二 区间DP
- Ruijie x32pro brush openwrt enable wireless 160MHz
- 商业智能BI的服务对象,企业管理者的管理“欲望”该如何实现?
- Uniapp native JS to convert the Gregorian calendar to the lunar calendar
- Enterprise data quality management: how to evaluate data quality?
- Db2 SQL PL中的控制语句
- SQL function
- Seata安装Window环境
- nodejs-基本架构分析-解析引擎目录-插件安装-核心模块
猜你喜欢

直播预告 | 社交新纪元,共探元宇宙社交新体验

Stream流的常用方法-Lambder

nodejs-基本架构分析-解析引擎目录-插件安装-核心模块

In the digital age, why should enterprises make digital transformation?

Adobe Premiere Foundation (animation) (VII)

Seata installing the window environment

Adobe Premiere基础-导入导出,合并素材,源文件编译,脱机(二)

AEC: analysis of echo generation causes and echo cancellation principle

基于ssm在线订餐系统设计与实现.rar(项目源码)

商业智能BI如何帮企业降低人力、时间和管理成本?
随机推荐
Ruijie x32pro brush openwrt enable wireless 160MHz
基于JSP的医院预约挂号平台设计与开发.zip(论文+项目源码)
Seata安装Window环境
【杂谈】恭喜自己获得CSDN专家称号,努力终会换来结果
[database language SPL] a simple and fast database language SPL
Dynamic SQL of DB2 SQL pl
什么是商业智能BI,谈谈商业智能BI的定义与作用
Adobe Premiere基础特效(卡点和转场)(四)
In 2021, the world's top ten analog IC suppliers: Ti ranked first, and skyworks' revenue growth was the highest
Linked List
Adobe Premiere Foundation (animation production - Flexible animation) (VIII)
AgI foundation, uncertain reasoning, subjective logic Ppt1
商业智能BI在企业的价值之:业务分析发展决策
“数字化转型,数据先行”,谈谈数据治理对企业来说到底有多重要
Adobe Premiere foundation - Import and export, merge materials, source file compilation, offline (II)
nodejs-判断系统类型-获取主机名称-执行控制台命令-中文乱码
Chapter 161 SQL function year
SQL function
直播预告 | 解构OLAP!新型多维分析架构范式全公开!Apache Doris 将带来五个重磅议题!
【代理】10分钟掌握正向代理和反向代理的本质区别