为了帮助网友解决“MFC,CEdit派生类与CreateView函数”相关的问题,学网通过互联网对“MFC,CEdit派生类与CreateView函数”相关的解决方案进行了整理,用户详细问题包括:RT,我想知道:MFC,CEdit派生类与CreateView函数,具体解决方案如下:
解决方案1:
这两天在试验CSplitterWnd类分割视图的问题,目前是这样一种情况,创建了CListView,CFormView,CEdit三个类的派生类,派生类分别为:CDictList,CDictPre,CDictInput,在MainFrm.h中定义了:
CSplitterWnd m_wndSplitter1;
重载了MainFrm的OnCreateClient函数,代码如下:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
if(!m_wndSplitter1.CreateStatic(this,1,2))
{
return FALSE;
}
//请注意下面这行代码
m_wndSplitter1.CreateView(0,0,RUNTIME_CLASS(CDictInput),CSize(150,200),pContext);//9行
m_wndSplitter1.CreateView(0,1,RUNTIME_CLASS(CDictPre),CSize(200,200),pContext);
return TRUE;
//return CFrameWnd::OnCreateClient(lpcs, pContext);
}
现在的问题是,如果我在CreateView函数中,使用RUNTIME_CLASS(CDictList)、RUNTIME_CLASS(CDictPre)则能编译运行,如将CDictInput(派生于CEdit)中,编译则会报错,错误信息为:
D:\C++code\MyDict\MainFrm.cpp(120) : error C2039: 'classCDictInput' : is not a member of 'CDictInput'
d:\c++code\mydict\dictinput.h(15) : see declaration of 'CDictInput'
D:\C++code\MyDict\MainFrm.cpp(120) : error C2065: 'classCDictInput' : undeclared identifier
请大家帮忙看看了!分少了点,满意可追加哦!
解决方案2:
classCDictInput 这个似乎是连写导致的报错吧。class CDictInput中间有个空格。
CDictInput没有定义,是因为你没有将定义它的头文件包含到使用它的cpp文件中。
有问题可以hi我,这个很简单的问题。
你选的时候选择CEditView作为基类吧,CEdit类可能不行。你把那个类删除掉,然后从CEditView派生一个视图类。可能是这样的,CreateView只能生成CView及其派生类的视图,其它类是不可以的。