error C2065: 'OnPaint' : undeclared identifier 是什么原因啊该如何处理
error C2065: 'OnPaint' : undeclared identifier 是什么原因啊???
#include<afxwin.h>
#include"Ruler.h"
CMyApp myApp;
//////////////////////////////////////////////////////////
//CMyApp member functions
BOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMainWindow;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////
// CMainWindow message map and member functions
BEGINE_MESSAGE_MAP(CMainWindow, CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()
CMainWindow::CMainWindow()
{
Create(NULL, _T("Ruler"));
}
void CMainWindow::OnPaint()
{
CPaintDC dc(this);
...
...
}
各位大虾帮我看看啊 ! ?? 本人也是刚刚学习MFC来着 ,按着书上写的
但编译后错误有12个:
--------------------Configuration: 标尺应用程序 - Win32 Debug--------------------
Compiling...
Ruler.cpp
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(22) : error C2065: 'OnPaint' : undeclared identifier
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(22) : error C2440: 'type cast' : cannot convert from 'int *' to 'void (__thiscall CWnd::*)(void)'
There is no context in which this conversion is possible
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(22) : error C2143: syntax error : missing ';' before '}'
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(22) : warning C4508: 'BEGINE_MESSAGE_MAP' : function should return a value; 'void' return type assumed
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(22) : error C2143: syntax error : missing ';' before ','
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(23) : error C2143: syntax error : missing ';' before '{'
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(23) : error C2447: missing function header (old-style formal list?)
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(23) : error C2143: syntax error : missing ';' before '}'
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(42) : error C2065: 'CRrush' : undeclared identifier
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(42) : error C2065: 'pOldBrush' : undeclared identifier
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(42) : error C2440: '=' : cannot convert from 'class CBrush *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(54) : error C2374: 'i' : redefinition; multiple initialization
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(48) : see declaration of 'i'
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(60) : error C2374: 'i' : redefinition; multiple initialization
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(48) : see declaration of 'i'
Error executing cl.exe.
Ruler.obj - 12 error(s), 1 warning(s)
------解决方案--------------------
OnPaint函数没有在头文件声明?BEGINE_MESSAGE_MAP应该是BEGIN_MESSAGE_MAP的笔误;CRrush应该是CBrush的笔误;i重复定义了。
------解决方案--------------------
你用的是非VC6吧,只是类型转化严格了,你自己改改类型转化就行了。
------解决方案--------------------
void CMainWindow::OnPaint()
{
CPaintDC dc(this);
...
...
}
怎么放到CMyApp.cpp中去了, 看你的头文件没有把OnPaing声明的头文件包含进来
------解决方案--------------------
头文件中没有声明吧。
afx_msg void OnPaint();
------解决方案--------------------
#include<afxwin.h>
#include"Ruler.h"
CMyApp myApp;
//////////////////////////////////////////////////////////
//CMyApp member functions
BOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMainWindow;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////
// CMainWindow message map and member functions
BEGINE_MESSAGE_MAP(CMainWindow, CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()
CMainWindow::CMainWindow()
{
Create(NULL, _T("Ruler"));
}
void CMainWindow::OnPaint()
{
CPaintDC dc(this);
...
...
}
各位大虾帮我看看啊 ! ?? 本人也是刚刚学习MFC来着 ,按着书上写的
但编译后错误有12个:
--------------------Configuration: 标尺应用程序 - Win32 Debug--------------------
Compiling...
Ruler.cpp
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(22) : error C2065: 'OnPaint' : undeclared identifier
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(22) : error C2440: 'type cast' : cannot convert from 'int *' to 'void (__thiscall CWnd::*)(void)'
There is no context in which this conversion is possible
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(22) : error C2143: syntax error : missing ';' before '}'
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(22) : warning C4508: 'BEGINE_MESSAGE_MAP' : function should return a value; 'void' return type assumed
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(22) : error C2143: syntax error : missing ';' before ','
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(23) : error C2143: syntax error : missing ';' before '{'
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(23) : error C2447: missing function header (old-style formal list?)
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(23) : error C2143: syntax error : missing ';' before '}'
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(42) : error C2065: 'CRrush' : undeclared identifier
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(42) : error C2065: 'pOldBrush' : undeclared identifier
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(42) : error C2440: '=' : cannot convert from 'class CBrush *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(54) : error C2374: 'i' : redefinition; multiple initialization
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(48) : see declaration of 'i'
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(60) : error C2374: 'i' : redefinition; multiple initialization
F:\MFC Windows 程序设计\SelfCode\标尺应用程序\Ruler.cpp(48) : see declaration of 'i'
Error executing cl.exe.
Ruler.obj - 12 error(s), 1 warning(s)
------解决方案--------------------
OnPaint函数没有在头文件声明?BEGINE_MESSAGE_MAP应该是BEGIN_MESSAGE_MAP的笔误;CRrush应该是CBrush的笔误;i重复定义了。
------解决方案--------------------
你用的是非VC6吧,只是类型转化严格了,你自己改改类型转化就行了。
------解决方案--------------------
void CMainWindow::OnPaint()
{
CPaintDC dc(this);
...
...
}
怎么放到CMyApp.cpp中去了, 看你的头文件没有把OnPaing声明的头文件包含进来
------解决方案--------------------
头文件中没有声明吧。
afx_msg void OnPaint();
------解决方案--------------------