Showing and Updating a Window

Although CreateWindow creates a window, it does not automatically display the window. Instead, it is up to you to display the window by using the ShowWindow function and to 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 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 WINDOWS.H. 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 Windows Programming Reference.)