|
Prev: CAsyncSocket handle inheritance
Next: confused
From: JY Kim on 28 May 2008 21:15 Hello. I am working with source which is not for MFC. It seems to be coded for their own class library. When I got this code, source file didn't included "stdAfx.h" and include some other header file. So it spawns lots of error message when I compile with MFC. One message is on function overloading code is as below. -- BOOL CEdit::Create(HINSTANCE hInstance, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID) { CWnd* pWnd = this; return pWnd->Create(_T("EDIT"), NULL, dwStyle, rect, pParentWnd, hInstance, (HMENU)nID, NULL); } -- in .h file -- class CEdit : public CWnd { DECLARE_RUNTIMECLASS(CEdit) // Constructors public: CEdit(); virtual ~CEdit(); BOOL Create(HINSTANCE hInstance, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID); .... .... -- error message is -- error C2511: 'Create' : overloaded member function 'int (struct HINSTANCE__ *,unsigned long,const struct tagRECT &,class CWnd *,unsigned int)' not found in 'CEdit' c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(2974) : see declaration of 'CEdit' -- parameters of declaration and definition is same and I wonder why I met this problem. parameters of Create() function in function body is next problem and I met error in start of function. Please help me solve this problem. Thanks.
From: Doug Harrison [MVP] on 28 May 2008 22:04 On Thu, 29 May 2008 10:15:22 +0900, JY Kim <jkim747.n0zpam(a)paran.com> wrote: >Hello. > >I am working with source which is not for MFC. It seems to be coded >for their own class library. >When I got this code, source file didn't included "stdAfx.h" and >include some other header file. >So it spawns lots of error message when I compile with MFC. >One message is on function overloading >code is as below. > >-- >BOOL CEdit::Create(HINSTANCE hInstance, DWORD dwStyle, const RECT& >rect, CWnd* pParentWnd, UINT nID) >{ > CWnd* pWnd = this; > return pWnd->Create(_T("EDIT"), NULL, dwStyle, rect, >pParentWnd, hInstance, (HMENU)nID, NULL); >} >-- > >in .h file > >-- >class CEdit > : public CWnd >{ > DECLARE_RUNTIMECLASS(CEdit) > >// Constructors >public: > CEdit(); > virtual ~CEdit(); > > BOOL Create(HINSTANCE hInstance, DWORD dwStyle, const RECT& >rect, CWnd* pParentWnd, UINT nID); >... >... >-- > >error message is > >-- >error C2511: 'Create' : overloaded member function 'int (struct >HINSTANCE__ *,unsigned long,const struct tagRECT &,class CWnd >*,unsigned int)' not found in 'CEdit' > c:\program files\microsoft visual >studio\vc98\mfc\include\afxwin.h(2974) : see declaration of 'CEdit' MFC has always had its own class named "CEdit". You're going to have to rename your class or put it in a namespace. Renaming is the better choice by far, because it would be confusing to have two classes named CEdit in an MFC program. It just wouldn't occur to an MFC user that "CEdit" means anything but MFC's CEdit. -- Doug Harrison Visual C++ MVP
From: Scott McPhillips [MVP] on 28 May 2008 22:07 MFC has a class named "CEdit" so you cannot make a class of your own with the same name. "JY Kim" <jkim747.n0zpam(a)paran.com> wrote in message news:2d0s34t0oi5d12q4lmu25vl7vn4ts8p4j5(a)4ax.com... > Hello. > > I am working with source which is not for MFC. It seems to be coded > for their own class library. > When I got this code, source file didn't included "stdAfx.h" and > include some other header file. > So it spawns lots of error message when I compile with MFC. > One message is on function overloading > code is as below. > > -- > BOOL CEdit::Create(HINSTANCE hInstance, DWORD dwStyle, const RECT& > rect, CWnd* pParentWnd, UINT nID) > { > CWnd* pWnd = this; > return pWnd->Create(_T("EDIT"), NULL, dwStyle, rect, > pParentWnd, hInstance, (HMENU)nID, NULL); > } > -- > > in .h file > > -- > class CEdit > : public CWnd > { > DECLARE_RUNTIMECLASS(CEdit) > > // Constructors > public: > CEdit(); > virtual ~CEdit(); > > BOOL Create(HINSTANCE hInstance, DWORD dwStyle, const RECT& > rect, CWnd* pParentWnd, UINT nID); > ... > ... > -- > > error message is > > -- > error C2511: 'Create' : overloaded member function 'int (struct > HINSTANCE__ *,unsigned long,const struct tagRECT &,class CWnd > *,unsigned int)' not found in 'CEdit' > c:\program files\microsoft visual > studio\vc98\mfc\include\afxwin.h(2974) : see declaration of 'CEdit' > -- > > parameters of declaration and definition is same and I wonder why I > met this problem. > parameters of Create() function in function body is next problem and I > met error in start of function. > > Please help me solve this problem. > Thanks. -- Scott McPhillips [VC++ MVP]
From: Joseph M. Newcomer on 28 May 2008 23:33 See below... On Thu, 29 May 2008 10:15:22 +0900, JY Kim <jkim747.n0zpam(a)paran.com> wrote: >Hello. > >I am working with source which is not for MFC. It seems to be coded >for their own class library. **** Does their class library define a class called "CEdit"? If so, consider it incompatible with MFC. **** >When I got this code, source file didn't included "stdAfx.h" and >include some other header file. >So it spawns lots of error message when I compile with MFC. **** So what header file are you including, and if it is stdafx.h, is it the stock one? **** >One message is on function overloading >code is as below. > >-- >BOOL CEdit::Create(HINSTANCE hInstance, DWORD dwStyle, const RECT& >rect, CWnd* pParentWnd, UINT nID) **** There is no CEdit method in MFC that looks like this. The only documented CEdit::Create is virtual BOOL CEdit::Create(DWORD dwStyle, const RECT & rect, CWnd * pParentWnd, UINT nID) so yes, the call is inconsistent with this, because it has an HINSTANCE parameter. **** >{ > CWnd* pWnd = this; **** The above line is silly **** > return pWnd->Create(_T("EDIT"), NULL, dwStyle, rect, >pParentWnd, hInstance, (HMENU)nID, NULL); **** The correct call is return CWnd::Create(_T("EDIT"), NULL, dwStyle, rect, pParentWnd, id); and there is no method of CWnd that takes an HINSTANCE, since there is no useful purpose served by this parameter. **** >} >-- > >in .h file **** Which .h file? I'm sure it has a file name, and it isn't called ".h" **** > >-- >class CEdit > : public CWnd >{ > DECLARE_RUNTIMECLASS(CEdit) > >// Constructors >public: > CEdit(); > virtual ~CEdit(); > > BOOL Create(HINSTANCE hInstance, DWORD dwStyle, const RECT& >rect, CWnd* pParentWnd, UINT nID); **** Do you see an instance parameter here? **** >... >... >-- > >error message is > >-- >error C2511: 'Create' : overloaded member function 'int (struct >HINSTANCE__ *,unsigned long,const struct tagRECT &,class CWnd >*,unsigned int)' not found in 'CEdit' > c:\program files\microsoft visual >studio\vc98\mfc\include\afxwin.h(2974) : see declaration of 'CEdit' **** This error message is absolutely correct, and is telling you exactly what you have done wrong; you have an incorrect Create call, because there is no method of CEdit that takes an HINSTANCE as its first parameter. Remove the HINSTANCE parameter! joe **** Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
|
Pages: 1 Prev: CAsyncSocket handle inheritance Next: confused |