2.2.6 Showing and Updating a Window

Although CreateWindow creates a window, it does not automatically display the window. Instead, your application must display the window by using the ShowWindow function and must update the window's client area by using the UpdateWindow function.

The ShowWindow function tells Windows to display the new window. For the application's main window, WinMain should call ShowWindow soon after creating the window and should pass the nCmdShow parameter to it. The nCmdShow parameter tells the application whether to display the window as an open window or as an icon. After calling ShowWindow, WinMain should call the UpdateWindow function. The following example illustrates how to show and update a window:

ShowWindow(hWnd, nCmdShow);  /* shows the window         */
UpdateWindow(hWnd);          /* sends a WM_PAINT message */

Note:

Normally, the nCmdShow parameter of the ShowWindow function can be set to any of the constants beginning with SW_ that are defined in the WINDOWS.H header file. The one exception is when the application calls ShowWindow to display its main window; then, it uses the nCmdShow parameter from the WinMain function. For a complete list of these constants, see the Microsoft Windows Programmer's Reference, Volume 2.