我在切分窗口时,发生如下错误:
:\Visual Studio\MyProjects\DataStr\MainFrm.cpp(90) : error C2275: 'CCodeView' : illegal use of this type as an expression
d:\visual studio\myprojects\datastr\codeview.h(13) : see declaration of 'CCodeView'先说明CCodeView是我切分窗口中得一个窗口,其基类是CView;顺便再问一下切分窗口我可以继承CFormView类,怎么实现???
:\Visual Studio\MyProjects\DataStr\MainFrm.cpp(90) : error C2275: 'CCodeView' : illegal use of this type as an expression
d:\visual studio\myprojects\datastr\codeview.h(13) : see declaration of 'CCodeView'先说明CCodeView是我切分窗口中得一个窗口,其基类是CView;顺便再问一下切分窗口我可以继承CFormView类,怎么实现???
{
if(!m_SplitterWnd1.CreateStatic(this,2,1))
{
TRACE0("Faile to splitter the window");
return false;
}
if(!m_SplitterWnd2.CreateStatic(&m_SplitterWnd1,1,2,WS_CHILD|WS_VISIBLE,m_SplitterWnd1.IdFromRowCol(0,0)))
{
TRACE0("Faile to splitter the window");
return false;
}
if(!m_SplitterWnd2.CreateView(0,0,CRuntimeClass(CGraphView),CSize(200,100),pContext))
{
TRACE0("Faile to splitter the window");
return false;
}
if(!m_SplitterWnd2.CreateView(0,1,CRuntimeClass(CCodeView),CSize(200,100),pContext))
{
TRACE0("Faile to splitter the window");
return false;
}
if(!m_SplitterWnd1.CreateView(1,0,CRuntimeClass(CControlView),CSize(0,0),pContext))
{
TRACE0("Faile to splitter the window");
return false;
} //return CFrameWnd::OnCreateClient(lpcs, pContext);
}
在MainFrm.h中申明:
CSplitterWnd m_wndSplitter通过类向导重载OnCreateClient函数
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
m_wndSplitter.CreateStatic(this, 1, 2);
m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CSpliterView),CSize(0, 0), pContext);
m_wndSplitter.CreateView(0, 1,RUNTIME_CLASS(CMyFormView),CSize(300, 0),pContext); return TRUE;
// return CFrameWnd::OnCreateClient(lpcs, pContext);
}如果编译出现类似错误
error C2143: syntax error : missing ';' before '*'
d:\workshop\study\spliter\spliterview.h(21) : error C2501: 'CSpliterDoc' : missing storage-class or type specifiers
d:\workshop\study\spliter\spliterview.h(21) : error C2501: 'GetDocument' : missing storage-class or type specifiers
SpliterDoc.cpp
请在应用程序类中加入文档类的头文件就可以了。如:
#include "SpliterDoc.h"