利用MFC时OnPaint的错误

按书上的操作,头文件中输入的代码如下:classCUseMFCLib:publicCWinApp{public:virtualBOOLInitInstance();};c... 按书上的操作,头文件中输入的代码如下:
class CUseMFCLib:public CWinApp
{
public:
virtual BOOL InitInstance();
};

class CUseMFCLibFrame:public CFrameWnd
{
public:
CUseMFCLibFrame();
protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP();
};
实现文件中的代码如下:
#include <afxwin.h>
#include "UseMFCLib.h"
CUseMFCLib near theAPP;
CUseMFCLibFrame *m_pMainWnd;
BOOL CUseMFCLib::InitInstance()
{
m_pMainWnd=new CUseMFCLibFrame();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}

BEGIN_MASSAGE_MAP(CUseMFCLibFrame,CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()
CUseMFCLibFrame::CUseMFCLibFrame()
{
Create(NULL,"First Application demo");
}

void CUseMFCLibFrame::OnPaint()
{
CPaintDC dc(this);
dc.TextOut(40,150,"hello!This is a example for how to create application");
}
错误如下:
E:\学习\C++\UseMFCLib\UseMFCLib.cpp(14) : error C2065: 'OnPaint' : undeclared identifier
E:\学习\C++\UseMFCLib\UseMFCLib.cpp(14) : error C2440: 'type cast' : cannot convert from 'int *' to 'void (__thiscall CWnd::*)(void)'
There is no context in which this conversion is possible
E:\学习\C++\UseMFCLib\UseMFCLib.cpp(14) : error C2143: syntax error : missing ';' before '}'
E:\学习\C++\UseMFCLib\UseMFCLib.cpp(14) : warning C4508: 'BEGIN_MASSAGE_MAP' : function should return a value; 'void' return type assumed
E:\学习\C++\UseMFCLib\UseMFCLib.cpp(14) : error C2143: syntax error : missing ';' before ','
E:\学习\C++\UseMFCLib\UseMFCLib.cpp(15) : error C2143: syntax error : missing ';' before '{'
E:\学习\C++\UseMFCLib\UseMFCLib.cpp(15) : error C2447: missing function header (old-style formal list?)
E:\学习\C++\UseMFCLib\UseMFCLib.cpp(15) : error C2143: syntax error : missing ';' before '}'
展开
 我来答
atgc123
2009-07-01 · TA获得超过2512个赞
知道小有建树答主
回答量:1773
采纳率:50%
帮助的人:1100万
展开全部
BEGIN_MASSAGE_MAP(CUseMFCLibFrame,CFrameWnd)
这一行中字母M后的字母A改成字母E
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式