MFC 新手,求指点迷津
初学MFC 敲了一个教程上面的程序上去,按照要求建立工程文件和设置“使用MFC类库”于是就出现了如下一堆错误,恳请知道!拜谢!同时,请各位豪杰指导下MFC的编程技巧和学习方法,感激…………
#include <afxwin.h>
class CMyWnd:public CFrameWnd
{
private:
char * Showtext;
public:
afx_msg void OnPaint();
afx_msg void OnLButtonDown();
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP (CMyWnd,CFrameWnd)
On_WM_PAINT()
On_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
void CMyWnd::OnPaint()
{
CPaintDC dc(this);
dc.TextOut(20,20,Showtext);
}
void CMyWnd::OnLButtonDown()
{
Showtext="my first try";
InvalidateRect(NULL,TRUE);
}
class CMyApp::public CWinApp
{
public:
BOOL InitInstance();
};
BOOL CMyApp::InitInstance()
{
CMyWnd * pMainWnd=new CMyWnd;
pMainWnd->Create(0,"MFC");
pMainWnd->ShowWindow(m_nCmdShow);
pMainWnd->UpdateWindow();
m_pMainWnd=pMainWnd;
return true;
}
CMyApp MyApp;
编译完整错误提示如下:
--------------------Configuration: 0 - Win32 Debug--------------------
Compiling...
0.cpp
D:\Program Files\DAEMON Tools Lite\0\0.cpp(14) : error C2065: 'On_WM_PAINT' : undeclared identifier
D:\Program Files\DAEMON Tools Lite\0\0.cpp(15) : error C2061: syntax error : identifier 'On_WM_LBUTTONDOWN'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(16) : error C2143: syntax error : missing ';' before '{'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(16) : error C2447: missing function header (old-style formal list?)
D:\Program Files\DAEMON Tools Lite\0\0.cpp(16) : error C2143: syntax error : missing ';' before '}'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(30) : error C2653: 'CMyApp' : is not a class or namespace name
D:\Program Files\DAEMON Tools Lite\0\0.cpp(30) : error C2589: 'public' : illegal token on right side of '::'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(30) : error C2589: 'public' : illegal token on right side of '::'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(30) : error C2589: 'public' : illegal token on right side of '::'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(30) : error C2143: syntax error : missing ';' before '::'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(30) : error C2143: syntax error : missing ';' before '::'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(31) : error C2143: syntax error : missing ';' before '{'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(31) : error C2447: missing function header (old-style formal list?)
D:\Program Files\DAEMON Tools Lite\0\0.cpp(36) : error C2027: use of undefined type 'CMyApp'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(30) : see declaration of 'CMyApp'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(39) : error C2018: unknown character '0xa3'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(39) : error C2018: unknown character '0xac'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(39) : error C2143: syntax error : missing ')' before 'string'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(39) : error C2660: 'Create' : function does not take 1 parameters
D:\Program Files\DAEMON Tools Lite\0\0.cpp(39) : error C2059: syntax error : ')'
D:\Program Files\DAEMON Tools Lite\0\0.cpp(40) : error C2065: 'm_nCmdShow' : undeclared identifier
D:\Program Files\DAEMON Tools Lite\0\0.cpp(42) : error C2065: 'm_pMainWnd' : undeclared identifier
D:\Program Files\DAEMON Tools Lite\0\0.cpp(42) : error C2440: '=' : cannot convert from 'class CMyWnd *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\Program Files\DAEMON Tools Lite\0\0.cpp(46) : error C2079: 'MyApp' uses undefined class 'CMyApp'
执行 cl.exe 时出错.
0.obj - 1 error(s), 0 warning(s)