Window window level relationship
I believe how many brothers who have been programmed under Window are very clear about the hierarchical relationship between WINDOW. This thing has been studied for a long time, and later forgot, today I have encountered this problem again, so I will finish it. Let's talk about the desktop and top window, and the relationship between the sub-window.
Under the Window graphical interface, the element of the most basic display information is the window, and each Window window manages the relationship between himself and other windows, such as: whether it is visible, the owner of the window, the father of the window / Sub-relations, etc., when the window is created, destroyed, when displayed, this will be used.
In each window instance, four elements are used by the window manager to create a window management linked list.
Child: Pointing the handle of the window sub-window: Pointing the handle of the window parent window Owner: Pointing the handle of the window owner Next: Point the handle of the next homogenic window
As we all know when Window is initialized, it creates a desktop window, covering the entire window, window manager uses this window as the first element in the window linked list. Therefore, the desktop is in the uppermost level of the hierarchy. In the window hierarchy, the next layer window is called the top window, and the top window is the window that is not a child window, and the top window cannot have a WS_CHILD property. How is the window manager linked to the desktop window and the top window? Window Manager organizes the top window into a list, and the header of this list is the sub-window handle of the desktop window, and each sub-window can find the next window in the linked list through next. This list is called a sub-window linked list, and the window in the same sub-window is interacting with each other, all top windows are similar windows. The sequence of the window in the sub-window chain also shows the distance from the window to the desktop window. The sub-window chain form formed by the top window constitutes a z-axis, and the window manager feels based on the Z sequence which part is displayed, which portion is covered. All top window of the top window is pointing to the desktop window, so that the top window is like a sub-window for the desktop window, and the linked list made of all top windows is a sub-window linked list of the desktop window. When the top window is created, the window manager places the top window on the top of the z-axis so that the entire window can be seen, the window manager inserts the window into the front of the desktop window linked list. WS_EX_TOPMOST This property controls the window manager to create a top window, and the window manager places the window without the WS_EX_TOPMOST property in the window with the WS_EX_TOPMOST property, so that the window with the WS_EX_TOPMOST property is displayed in front. There is also another relationship between the top window, owns or belonging to the other top window, and the window belonging to other windows is called the home window, which has other windows called the host window. In the z-axis, the home window must be in front of his host window. If a host window minimizes, the home window will hide, if the host window hides, the home window will not be hidden. If there are three windows A, B, C, A have b, b has C, if A minimizes, then B will hide, but C is still visible. How can I build all relationships between the window? The method is to specify the hwndparent parameter when calling CREATEWINDOW or CREATEWINDOWEX to create a window. The desktop window is the first layer in the window level, the top window in the window hierarchy, the sub-window is the window that specifies the WS_CHILD attribute when it is created. Other layers of the window hierarchy. The link between the window and the sub-window is like the relationship between the desktop window and the top window. The sub-window displays the customer area of its parent window, and the sub-window of all the same window also creates a z-axis. This and the top window are similar, the top window is also a client area that is displayed in its parent window - desktop window. The difference between 16-bit and 32-bit window systems
The parent child relationship between the window, all the relationships, and these rules displayed according to the z-axis are the same in the 16-bit and 32-bit window systems. This can be highly compatible in the two window systems. The difference between the two window systems is security and multithreading. Window NT adds a layer in the original window hierarchy, each with a Window workstation object in the system running Window NT, this object is the first floor of the security object, which is the source of all user security objects. Each Window workstation object can have some desktop objects, each desktop has the window relationship as described above. Window NT uses two desktop window objects, one is used to handle the login interface, mask, lock the workstation, etc., one is the window that we come in after landing. J Usually the user cannot create and delete the desktop, but that is usually, in fact, under Window, you can also implement multiple desktops in Linux, each desktop is an independent world. Two window systems have two different distins, do not support multithreading in the 16-bit window system, so application developers do not have to consider threads when creating a window. In the 32-bit window system, due to the parent-child relationship of the window, all threads under the same window, all threads below the same window have the same input queue, application developers should understand that the input queue is shared, There is only one thread to process messages, and other threads are waiting for the input queue until getMessage or peekMessage returns, and must be noted that the parent window and sub-window or the home with the ownership of the same thread. Define two new window types, front-end windows, and background windows in the 32 window system. These two windows are not listed in the hierarchical relationship of the window. The front desk is the window of the user's current operation, and all the other windows are the background window. Two functions support two functions in the 32-bit window system to process the front desk setForegroundWindow and GetForegroundWindow. Operation window list
Below is some functions of the window list operation: Ø EnumChildWindows uses this function to get all the sub-windows of a window, including sub-windows. However, this function is not able to list the window being created or destroyed in the process. Ø EnumthReadwindows use this function to list all windows that belong to this thread. The window created after this function call is not enumerated. Ø EnumWindows uses this function to list all top windows, not to list the child window, to list all top windows, use this function than getWindow security. Use getWindow to list all windows, may result in an unlimited loop because some windows may have been destroyed in the process of calling getWindow. EnumWindows cannot list the top window created after calling this function. Ø FindWindow can use this function to find the top window by class name or using the title of the window, this function cannot be used to find the child window, this function does not distinguish the case case. This function is looking for a window in the Z axis. After finding it, it will return. Ø getDesktopWindow gets the desktop window handle Ø getNextWindow Using this function to get the same window of this window, getNextWindow and getWindow in the 16-bit window system are two different functions, and this function is implemented through getWindow in the 32-bit system. Ø getParent If a window exists, you can get the parent window of the window through this function. If the window is a top window, return it to its owner window handle. Ø GetThReadDesktop This function is used to get the desktop handle of the specified thread, in Win95 and Win98, because multiple desktops are not supported, each time the function returns the same value. Ø GetTopWindWind You can use this function to get the handle of the first sub-window of a given window. If the parameter passed to the function is null, then this function will return the top top window. Ø GetWindow application can call this function to navigate in the window list, this function has two parameters, one is the handle of the window, and the relationship between the window handle and this window is additionally. · GW_HWndNext: This function returns the next homage window for a given window · GW_HWndFirst: Returns the previous homologous window of the given window · GW_HWndlast: Returns the last homage window of the given window · GW_HWNDPREV: Return to the first assignment of the given window Window · GW_OWNER: Returns the owner window of the given window Handle · GW_CHILD: Returns the first child window of the given window Ø Ischild This function has two parameters, two window handles, judge whether the two windows have a father and child relationship
Window properties
When the application calls CREATEWINDOW creates a window, we must specify an attribute for the window, which briefly introduces the properties of the window. WS_OVERLAPPED
Randlation attributes are an attribute of the top window. Use this property created by this property that will be linked to the sub-window list of the desktop window. The application usually uses this property window as the main window of the application, with overlaps The attribute window usually has a title bar, even if the attribute of WS_CAPTION is not specified. Windows with overlapsing properties are usually borders, with windows with overlap properties, you can have your own top window, or you can have other top-level windows, all such windows have a ws_clipsiblings property, even if it is not given to the window This property is.
The WS_POPUP pop-up attribute is also an attribute applied to the top-level window. The window created using this property will be linked to the sub-window list of the desktop window, the application is usually set to set this property for the dialog window, pop-up attributes and overlap the properties. The main difference is that a window with pop-up attributes is not necessarily a title bar, and a window with overlap the properties must have a title bar that has a window with pop-up attributes. No border. As with a window with overlap the properties, a window with pop-up properties can have its own window, or other top-level windows. All windows with pop-up properties must have a WS_Clipsibings property, even if the user does not specify this property. The window with pop-up attributes is created, its size and location cannot be used with a CW_USEDEFAULT value. The WS_CHILD sub-window must have this property, and the sub-window can only appear in the client area of the parent window, which is the main difference between the sub-window and the window with overwundering properties, and the window of the pop-up attribute. When the sub-window is created, the location and size is not Can use CW_USEDEFAULT this value, otherwise it is not possible to create a window.
WS_CAPTION When the window is set, the window will have the title bar, the application can change the title bar to the title bar, usually with the window of the title bar, which has the largest, smallest, shutdown button, and the system. menu. If a window does not have a title bar, then Window does not create these things, even if the user specifies these properties, the system menu exists depending on the existence of the title bar window. If there is no title bar, there will be no system menu The existence. Windows with the title bar typically have a single line with an attribute that can change the window size, and usually have a title bar that does not have boundary properties of the dialog, unless set the WS_EX_DLGMODALFRAME attribute to the window.
WS_MINIMIZEBOX When setting up this property for the window, there will be a minimized button on the title bar of the window. In fact, when this property is implemented, it is just a minimized bitmap on the title bar, when the user clicks When this minimize bit map, the window minimizes, and if the maximum bitmap is most, the minimum bitmap is placed on the left side of the maximum bitmap. Windows without this property cannot be minimized.
WS_MAXIMIZEBOX When setting this property for the window, the top right of the window's title bar will be placed a maximized bitmap. If the window sets this property, the user can click the maximum bitmap or through the system menu to implement the window. Maximize, the window without this property cannot be maximized.
WS_SYSMENU If you specify this property for the window, then place the system menu bitmap in the upper left corner of the window, the system menu provides the user with the interface of the operation window, usually the system menu will have the following system command:
Restore minimized window Use the keyboard mobile window to use the keyboard change window Size the size of the window to maximize the window to switch to other tasks If a window has a system menu, the user can call the system menu by clicking the system menu icon, or through Alt The shortcuts of the space call out the system menu, or call up the system menu by clicking the icon on the taskbar, if a window does not have the system menu, then the user cannot implement the system command through the keyboard, unless the application itself provides such interface. The system menu is also very useful for maximizing the window, the maximized window covers the entire screen, such a window cannot be moved unless it is not a maximized state, if this maximized window has a system menu, It is not necessary to restore the state of non-maximation to move.
WS_HSCROLL If the window is specified this property, then the window will have a horizontal scroll bar, the window does not scroll scroll bar, if the application is to support the scroll bar, then you must handle the WM_HSCROLL message yourself, this property is usually When the window is created, it is specified. WS_VSCROLL If this property is specified, then the window will have a vertical scroll bar, the window does not scroll scroll bar, the application must handle the WM_VSCROOL message to handle the scroll bar scrolling message, this property is usually in the window. Specified when creating.
WS_BORDER If the window is specified this property, then the window will have a single line around the window, if this property is not specified, but the window has a title bar, then the window will automatically own this property, if the window does not have this property, own The window of this property cannot be changed by the keyboard or the mouse changes the size of the window.
WS_DLGFRAME If the window is specified, the window has the border of the dialog, which is usually used in the dialog window, which can only be used in the window without the title bar, if one is not a dialog box, using this The window must be specified by the WS_EX_DLGMODALFRAME attribute. Use the window created with this property, you cannot change the size of the window through the keyboard and the mouse.
WS_THICKFRAME When the window is specified, the window will have a border that can change the size, which is usually used in the main window of the program, and the size of the window with this property can be changed by the keyboard or mouse.
WS_CLIPCHILDREN This property is used in a window with a sub-window. Use this property to copy the area occupied by the sub-window to the parent window instead of the area to which the parent window is directly related, if the window does not specify this property Then then the parent window covers the area of the sub-window. In some pictures displayed or OpenGL displayed, it is important to specify this attribute.
WS_CLIPSIBLINGS When the window gives this property, the window does not draw the same sub-window, all the window with overlapsing properties and pop-up properties have this property, all the top-level windows have this property, so The top window is not drawn when it is painted, and does not draw on the top window.
WS_Visible When the window is set, the window is visible, in the default, the application must call ShowWindow yourself to display the window.
WS_DISABLED When the window is set this property, the created window cannot accept the user's input, unless the application itself provides a way to enter. This property is usually used on the Window control.
WS_CHILDWINDOW This property is with WS_CHILD. WS_OVERLAPPEDWINDOW This property is with WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIMIMIMIMIMIZEBOX | WS_MAXIMIZEBOX, this property is usually used in the main window of the application. WS_POPUPWINDOW This property is with WS_POPUP | WS_BORDER | WS_SYSMENU, although this property contains the ws_sysmenu attribute, if the window does not have a WS_CAPTION property, the window does not have a system menu.
WS_EX_DLGMODALFRAME When the window sets this property, the window has the border of the dialog, which is usually used in the dialog window, but any window can use this property to get the border of the dialog.
WS_EX_NOPARETNOTIFY This property is used on a sub-window. When the child window sets this property, Window does not send the WM_NOTIFY message to the parent window of the child window. By default, Window will send WM_NOTIFY messages when you create or destroy it in the sub-window. The parent window of the window. WS_EX_TOPMOST This property is only used on the top window. It is ignored to the sub-window setting. If this property is set, the window will always be on the other window. The WS_EX_ACCEPTFILES window sets this property, then the window can accept the object of drag and drop.
WS_EX_TRANSPARENT This property enables the window to transparent, set the background of the window that can be seen, the transparent window is not transparent to the mouse and keyboard message events.