BOOL ShowWindow(hwnd, nCmdShow) | |||||
HWND hwnd; | /* handle of window | */ | |||
int nCmdShow; | /* window visibility flag | */ |
This function displays or removes the given window, as specified by the nCmdShow parameter.
hwnd
Identifies the window.
nCmdShow
Specifies how the window is to be shown. It must be one of the following values:
Value | Meaning |
SW_SHOWDEFAULT | ||
This should be used by an application during startup. It tells Windows to show the main window with the “default” SW_* command. This is usually the SW_* command passed in through the STARTUPINFO structure passed to CreateProcess. | ||
SW_HIDE | ||
Hides the window and passes activation to another window. | ||
SW_MINIMIZE | ||
Minimizes the specified window and activates the top-level window in the window-manager's list. | ||
SW_RESTORE | ||
Same as SW_SHOWNORMAL. | ||
SW_SHOW | ||
Activates a window and displays it in its current size and position. However, if the first call by an application to ShowWindow has nCmdShow set to SW_SHOW, the system will use the startup information mentioned in the discussion of SW_SHOWDEFAULT. See the Comments section for additional information concerning this behavior. | ||
SW_SHOWMAXIMIZED | ||
Activates the window and displays it as a maximized window. | ||
SW_SHOWMINIMIZED | ||
Activates the window and displays it as iconic. | ||
SW_SHOWMINNOACTIVE | ||
Displays the window as iconic. The window that is currently active remains active. | ||
SW_SHOWNA | ||
Displays the window in its current state. The window that is currently active remains active. | ||
SW_SHOWNOACTIVATE | ||
Displays a window in its most recent size and position. The window that is currently active remains active. | ||
SW_SHOWNORMAL | ||
Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. | ||
SW_SHOWSMOOTH | ||
Specifies that a window is shown by first having it update in a bitmap, and then copying those bits directly to the screen. In many cases this will improve the perceived speed because copying from an off-screen bitmap to the screen is very fast, making the window “snap” onto the screen. |
The return value specifies the previous state of the window. It is nonzero if the window was previously visible. It is zero if the window was previously hidden.
The ShowWindow function must be called only once per program with the nCmdShow parameter from the WinMain function. Subsequent calls to ShowWindow must use one of the values listed above, instead of one specified by the nCmdShow parameter from the WinMain function.
As noted in the discussion of the nCmdShow parameter, it is recommended that applications call ShowWindow with nCmdShow set to SW_SHOWDEFAULT in order to use application startup information that affects window display. For example, the Program Manager might want the application to start up with a minimized window. However, the Windows 32 system will also use the application startup information on the very first call by an application to ShowWindow when it is called with nCmdShow set to SW_SHOW. This behavior is designed for the following situations:
Applications that create their initial window by calling CreateWindow with the WS_VISIBLE flag set.
Applications that create their initial window by calling CreateWindow without the WS_VISIBLE flag, and later call ShowWindow with SW_SHOW to make it visible.
ShowOwnedPopups, CreateWindow