Win32 App里面输入以下代码#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="Message_mapped Program";
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;编译之前选择Project|settings菜单,静态实用MFC类库这是一个书本上的原题,编译之后出现如下错误:Compiling...
main.cpp
E:\MFC\MFC_Eg0205\main.cpp(10) : error C2018: unknown character '0xa3'
E:\MFC\MFC_Eg0205\main.cpp(10) : error C2018: unknown character '0xbb'
E:\MFC\MFC_Eg0205\main.cpp(12) : error C2143: syntax error : missing ';' before '*'
E:\MFC\MFC_Eg0205\main.cpp(12) : error C2501: 'GetMessageMap' : missing storage-class or type specifiers
E:\MFC\MFC_Eg0205\main.cpp(12) : error C2556: 'int *__thiscall CMyWnd::GetMessageMap(void) const' : overloaded function differs only by return type from 'const struct AFX_MSGMAP *__thiscall CMyWnd::GetMessageMap(void) const'
E:\MFC\MFC_Eg0205\main.cpp(9) : see declaration of 'GetMessageMap'
E:\MFC\MFC_Eg0205\main.cpp(12) : error C2373: 'GetMessageMap' : redefinition; different type modifiers
E:\MFC\MFC_Eg0205\main.cpp(9) : see declaration of 'GetMessageMap'
E:\MFC\MFC_Eg0205\main.cpp(12) : error C2143: syntax error : missing ';' before 'tag::id'
E:\MFC\MFC_Eg0205\main.cpp(12) : error C2734: 'AFX_MSGMAP' : const object must be initialized if not extern
E:\MFC\MFC_Eg0205\main.cpp(12) : error C2371: 'AFX_MSGMAP' : redefinition; different basic types
E:\MFC\MFC_Eg0205\main.cpp(12) : see declaration of 'AFX_MSGMAP'
E:\MFC\MFC_Eg0205\main.cpp(12) : fatal error C1004: unexpected end of file found
Error executing cl.exe.main.obj - 10 error(s), 0 warning(s)请帮忙看一看是不是缺少了什么?
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="Message_mapped Program";
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;编译之前选择Project|settings菜单,静态实用MFC类库这是一个书本上的原题,编译之后出现如下错误:Compiling...
main.cpp
E:\MFC\MFC_Eg0205\main.cpp(10) : error C2018: unknown character '0xa3'
E:\MFC\MFC_Eg0205\main.cpp(10) : error C2018: unknown character '0xbb'
E:\MFC\MFC_Eg0205\main.cpp(12) : error C2143: syntax error : missing ';' before '*'
E:\MFC\MFC_Eg0205\main.cpp(12) : error C2501: 'GetMessageMap' : missing storage-class or type specifiers
E:\MFC\MFC_Eg0205\main.cpp(12) : error C2556: 'int *__thiscall CMyWnd::GetMessageMap(void) const' : overloaded function differs only by return type from 'const struct AFX_MSGMAP *__thiscall CMyWnd::GetMessageMap(void) const'
E:\MFC\MFC_Eg0205\main.cpp(9) : see declaration of 'GetMessageMap'
E:\MFC\MFC_Eg0205\main.cpp(12) : error C2373: 'GetMessageMap' : redefinition; different type modifiers
E:\MFC\MFC_Eg0205\main.cpp(9) : see declaration of 'GetMessageMap'
E:\MFC\MFC_Eg0205\main.cpp(12) : error C2143: syntax error : missing ';' before 'tag::id'
E:\MFC\MFC_Eg0205\main.cpp(12) : error C2734: 'AFX_MSGMAP' : const object must be initialized if not extern
E:\MFC\MFC_Eg0205\main.cpp(12) : error C2371: 'AFX_MSGMAP' : redefinition; different basic types
E:\MFC\MFC_Eg0205\main.cpp(12) : see declaration of 'AFX_MSGMAP'
E:\MFC\MFC_Eg0205\main.cpp(12) : fatal error C1004: unexpected end of file found
Error executing cl.exe.main.obj - 10 error(s), 0 warning(s)请帮忙看一看是不是缺少了什么?
解决方案 »
- 如何使自己新建的类,用MFC来管理?
- 现在用VC语言进行数据库编程有没有更容易地方案
- 谁测试过在进程自己内安装消息钩子[不是全局钩子,是自己安装在自己身上的消息钩子],我测试了,不行过滤自己进程的。你们有测试过吗?
- 高手进来看看,关于多播地址
- 特请masterz或其他各位帮忙,解决问题!!
- "0x5f480f2a"指令引用的"0x00000004"内存。改内存不能为"read"
- 喜得千金,请各位兄弟帮忙起个名字。up有分!
- AppWizard自动生成代码的问题?
- 一个很菜的问题!
- 问个简单问题: 用MFC作ActiveX控件OCX, 怎么收不到VB传过来的数组, 我用VARIANT...
- 菜单和自建view的消息映射 急!急!急!
- 自己添加的treectrl消息映射不响应,OnSelChangedTree()映射
class CMyWnd:public CFrameWnd
{
private:
char* ShowText;
public:
afx_msg void OnPaint();
afx_msg void OnLButtonDown();
DECLARE_MESSAGE_MAP()
};//<===这里的分号是中文字符,其它类似的自己找找。