Visual C++ and MFC Fundamentals Chapter 12: Dialog-Based Windows
RegisterClassEx(&WndClsEx);
hWnd = CreateWindowEx(0,
StrClassName,
StrWndName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if( !hWnd )
return 0;
return 0;
}
//---------------------------------------------------------------------------
- Save All
10.2.8..Window Display..................................................................................
Once a window has been created and if this was done successfully, you can display it to
the user. This is done by calling the ShowWindow() function. The Win32 version of this
function has the following syntax:
BOOL ShowWindow(HWND hWnd, int nCmdShow);
The hWnd argument is a handle to the window that you want to display. It could be the
window returned by the CreateWindow() or the CreateWindowEx() function.
The nCmdShow specifies how the window must be displayed. It uses one of the
nCmdShow values above.
To show its presence on the screen, the window must be painted. This can be done by
calling the UpdateWindow() function. Its syntax is:
BOOL UpdateWindow(HWND hWnd);
This function simply wants to know what window needs to be painted. This window is
specified by its handle.
Practical Learning: Displaying the Window
- To show the window, call the ShowWindow() and the UpdateWindow() functions
as follows:
//---------------------------------------------------------------------------
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
HWND hWnd;