ShowWindow

Syntax

BOOL ShowWindow(hWnd,nCmdShow)

This function displays or removes the given window, as specified by the nCmdShow parameter.

Parameter Type/Description  

hWnd HWND Identifies the window.  
nCmdShow int Specifies how the window is to be shown. It must be one of the values shown in Table 4.18, “Window States.”  

Return Value

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.

Comments

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. Table R.18 lists the values for the nCmdShow parameter:

Table R.18 Window States

Value Meaning

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.
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.