Home > Back-end >  The error C2065: "pMainWnd" : no statement identifier for this mistake how to solve
The error C2065: "pMainWnd" : no statement identifier for this mistake how to solve

Time:09-15



#include
HINSTANCE hInst,
HINSTANCE HINSTANCE,
MSG MSG.
Char lpszClassName []="window_class";
Char * ShowText;

LRESULT a CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
Void OnLButtonDown (HWND HWND, UINT message, WPARAM WPARAM, LPARAM LPARAM);
Void OnPaint (HWND HWND, UINT message, WPARAM WPARAM, LPARAM LPARAM);
Void OnDestroy (HWND HWND, UINT message, WPARAM WPARAM, LPARAM LPARAM);

The class CFrameWnd
{
Public:
The HWND HWND;
Public:
Int RegisterWindow ();
Void the Create (LPCTSTR lpClassName,
LPCTSTR lpWindowName);
Void ShowWindow (int nCmdName);
Void UpdateWindow ();
};

Int CFrameWnd: : RegisterWindow ()
{
WNDCLASS wc.
Wc. Style=0;
Wc. LpfnWndProc=WndProc;
Wc. CbClsExtra=0;
Wc. CbWndExtra=0;
The wc. The hInstance=hInstance;
Wc. HIcon=LoadIcon (NULL, IDI_APPLICATION);
Wc. HCursor=LoadCursor (NULL, IDC_ARROW);
Wc. HbrBackground=(HBRUSH) GetStockObject (WHITE_BRUSH);
Wc. LpszMenuName=NULL;
Wc. LpszClassName=lpszClassName;
Return RegisterClass (& amp; Wc);
}

Void CFrameWnd: : Create (LPCTSTR lpClassName, LPCTSTR lpWindowName)
{
RegisterWindow ();
HInst=hInstance;
HWnd=CreateWindow (lpszClassName,
LpWindowName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
HInstance,
NULL);
}

Void CFrameWnd: : ShowWindow (int nCmdShow)
{
: : ShowWindow (hWnd, nCmdShow);
}

Void CFrameWnd: : UpdateWindow ()
{
: : UpdateWindow (hWnd);
}

Class CWinApp
{
Public:
CWinApp * m_pCurrentWinApp;
Public:
CWinApp ();
~ CWinApp ();
Public:
CFrameWnd * m_pMainWnd;
Public:
Virtual BOOL InitInstance (int nCmdShow);
Int the Run ();
};

CWinApp: : CWinApp ()
{
M_pCurrentWinApp=this;
}

BOOL CWinApp: : InitInstance (int nCmdShow)
{
M_pMainWnd=new CFrameWnd;
M_pMainWnd - & gt; Create (NULL, "encapsulation of Windows program");
M_pMainWnd - & gt; ShowWindow (nCmdShow);
M_pMainWnd - & gt; UpdateWindow ();
return TRUE;
}

Int CWinApp: : Run ()
{
While (GetMessage (& amp; MSG, NULL, 0, 0))
{
TranslateMessage (& amp; MSG);
DispatchMessage (& amp; MSG);
}
Return MSG. WParam;
}

CWinApp: : ~ CWinApp ()
{
The delete m_pMainWnd;
}

The class CmyWnd: public CFrameWnd
{
};

Class CMyApp: public CWinApp
{
Public:
BOOL InitInstance (int nCmdShow);
};
Int CMyApp: : InitInstance (int nCmdShow)
{
CMyWnd * pMainWnd;
PMainWnd=new CMyWnd;
PMainWnd - & gt; Create (NULL, "a program using a form of the derived class");
PMainWnd - & gt; ShowWindow (nCmdShow);
PMainWnd - & gt; UpdateWindow ();
M_pMainWnd=pMainWnd;
return TRUE;
}

CMyApp MyApp.

CWinApp * AfxGetApp ()
{
Return MyApp. M_pCurrentWinApp;
}

CodePudding user response:

Personal think the way the SDK pure API writing Windows programs have been out of date, efficiency is too low, it is ok to understand the principle, main is message mechanism,

A graphical user interface (GUI) programming can learn c + + Builder, advanced architecture (and c # drag controls), introduction to more easily,

C + + Builder is a real visual Development tool, c + + Builder can use the mouse to drag controls followed by a "design" set properties of a graphical user interface of the program, using the visual components/controls like "building blocks", built in the form of "wysiwyg" Application interface, which is the name of c + + Builder in the concept of the Builder, in this way, only needs to be written in c + + language business logic code, similar to the text interface programming under DOS, just concentrate on the business logic function, the code is very concise, data input and performance, in a graphical user interface, intuitive, and easy to use, this is RAD (Rapid Application Development, Rapid Application Development),

Book recommendation:
"C + + Builder 6 program design course (second edition)" (such as loyal lu, wen-liang liu/2011-04-01/science press) (dangdang)
"C + + Builder 6 programming examples of fine solution" (Zhao Mingxian), PDF, is a digital version, a scan version, there is also a complete implementation of tetris game,
"Wonderful" c + + Builder 6 programming Wu Yixian (Taiwan), there are a few simple little game, 10 can read later rewrite, is their mastery of the,
"C + + Builder 5 senior programming examples of fine solution" (written by Liu Bin) are larger practical program,

C + + Builder books download:
https://pan.baidu.com/s/13n9hxwVj9ai1p5L2rQC83Q

CodePudding user response:

If no statement in your header file
  • Related