Visual C++ and MFC Fundamentals Chapter 12: Dialog-Based Windows
WNDPROC lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HINSTANCE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCTSTR lpszMenuName;
LPCTSTR lpszClassName;
} WNDCLASS, *PWNDCLASS;
If you are creating an MFC application, you can declare a WNDCLASS variable in your
frame constructor. Here is an example:
#include <afxwin.h>
// The application class
class CExerciseApp : public CWinApp
{
public:
// Used to instantiate the application
BOOL InitInstance();
};
// The class that displays the application's window
// and gives it "physical" presence (Real Estate)
class CMainFrame : public CFrameWnd
{
public:
// The window class will be created in this constructor
CMainFrame();
};
CMainFrame::CMainFrame()
{
// Declare a window class variable
WNDCLASS WndCls;
}
BOOL CExerciseApp::InitInstance()
{
// Initialize the main window object
m_pMainWnd = new CMainFrame();
// Hoping everything is fine, return TRUE
return TRUE;
}
// The global application object
CExerciseApp theApp;
Upon declaring a WNDCLASS variable, the compiler allocates an amount of memory
space for it, as it does for all other variables. If you think you will need more memory
than allocated, assign the number of extra bytes to the cbClsExtra member variable.
Otherwise, the compiler initializes this variable to 0. If you do not need extra memory for
your WNDCLASS variable, initialize this member with 0. If you are creating an MFC
application, you can omit initializing the cbClsExtra member variable. Otherwise, you
can do it as follows: