Displaying a Window

You can control a window's visibility by using the ShowWindow or SetWindowPos function or by turning 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 its descendants will be drawn on the screen. 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 might have the WS_VISIBLE style turned on and still not be visible if it has a parent or ancestor window with the WS_VISIBLE style turned off.

To determine if a window is visible, call the IsWindowVisible function. This function checks the window and its ancestors to determine if the window is visible. A window might be considered visible but might not appear on the screen 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 might keep a new window hidden while it customizes the window appearance.

Changing the visibility of a window does not automatically change the visibility of windows that 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.