Chapter 12: Dialog-Based Windows Visual C++ and MFC Fundamentals
WndClsEx.lpszMenuName = NULL;
WndClsEx.lpszClassName = StrClassName;
WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
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;
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while( GetMessage(&Msg, NULL, 0, 0) )
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return 0;
}
//---------------------------------------------------------------------------
LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
lParam)
{
switch(Msg)
{
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
//---------------------------------------------------------------------------
- To test the application, if you are using MSVC 6, on the main menu, click Build ->
Set Active Configuration and, on the Set Active Project Configuration dialog box,
click Win32B Win32 Release: