Visual C++ and MFC Fundamentals Chapter 12: Dialog-Based Windows
Practical Learning: Setting the Window Name
- To provide a name for the window, declare and initialize a null-terminated string and
pass its value as the lpWindowName argument of the CreateWindowEx() function:
#include <windows.h>
//---------------------------------------------------------------------------
char StrClassName[] = "Win32Exercise";
char StrWndName[] = "Simple Win32 Application";
//---------------------------------------------------------------------------
LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM
lParam);
//---------------------------------------------------------------------------
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
HWND hWnd;
WNDCLASSEX WndClsEx;
RegisterClassEx(&WndClsEx);
hWnd = CreateWindowEx(0,
StrClassName,
StrWndName, );
return 0;
}
//---------------------------------------------------------------------------
- Save All
10.2.4..Windows Styles...................................................................................
We had a formal introduction to windows styles in Lesson 2 and we reviewed all
necessary styles to apply or not apply to a main window. Once again, a
WS_OVERLAPPEDWINDOW has a caption that displays the window name (if any). It
is also equipped with the system menu, a thick frame, a system Minimize button, a
system Maximize button, and a system Close button.
For a Win32 application, you can apply the WS_OVERLAPPEDWINDOW style as
follows:
CreateWindow(ClsName, WndName, WS_OVERLAPPEDWINDOW,
For an MFC application, this style can be added as follows:
CMainFrame::CMainFrame()
{
// Declare a window class variable
WNDCLASS WndCls;
const char *StrWndName = "Windows Fundamentals";