Displaying the Window

After the CreateWindow call returns, the window has been created internally in Windows. However, the window does not yet appear on the video display. Two more calls are needed. The first is:

ShowWindow (hwnd, nCmdShow) ;

The first parameter is the handle to the window just created by CreateWindow. The second parameter is the nCmdShow value passed as a parameter to WinMain. This determines how the window is to be initially displayed on the screen. If nCmdShow is SW_SHOWNORMAL (equal to 1), the window is displayed normally. If nCmdShow is SW_SHOWMINNOACTIVE (equal to 7), then the window is initially displayed as an icon.

The ShowWindow function puts the window (or icon) on the display. If the second parameter to ShowWindow is SW_SHOWNORMAL, the client area of the window is erased with the background brush specified in the window class. The function call:

UpdateWindow (hwnd) ;

then causes the client area to be painted. It accomplishes this by sending the window procedure (the WndProc function in HELLOWIN.C) a WM_PAINT message. We'll examine shortly how WndProc deals with this message.