Window Visibility

You can control a window's visibility by using the ShowWindow or SetWindowPos functions to turn its WS_VISIBLE style on or off. Think of the WS_VISIBLE style as a way to hide a window. If this style is turned off, neither the window nor any of its descendants will be drawn on the screen. In other words, hiding a window hides the window itself, as well as all of its children, all of their children, and so on. Even though a child window is hidden when its parent is hidden, the child window's WS_VISIBLE style is not changed when its parent's style is changed. A child window may have the WS_VISIBLE style turned on and still not be visible, if it has a parent or ancestor window with a WS_VISIBLE style turned off.

You can use the IsWindowVisible function to determine whether or not a window is visible. This function checks the window and its ancestors to determine if the window is visible. A window may be considered visible, but may not appear on the display, if it is covered by other windows.

By default, the CreateWindowEx function creates a hidden window, unless you specify the WS_VISIBLE style. Typically, an application sets the WS_VISIBLE style after it has created a window to keep details of the creation process hidden from the user. For example, an application may keep a new window hidden while it customizes the window's appearance.

Changing the visibility of a window does not automatically change the visibility of any windows it owns. Also, if you create a dialog box whose parent window is not visible, the dialog box will be visible. To avoid this inconsistency, do not create a dialog box that is owned by an invisible window.