新建一个SDI工程,打算静态分割窗口。添加CRightTopView、CRightBttmView,为CMainFrame添加CSplitterWnd类型的变量m_wndSplitter,m_wndSplitterRight在MainFrm.cpp重载CFrameWnd::OnCreateClient(lpcs, pContext)函数时,添加如下代码:
CRect rect;
GetClientRect(rect);
CSize paneSize(rect.Width()/2,rect.Height());
m_wndSplitter.CreateStatic(this,1,2);
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CSDIView),paneSize,pContext);
paneSize.SetSize(paneSize.cx,paneSize.cy/2);
m_wndSplitterRight.CreateStatic(&m_wndSplitter,2,1,WS_CHILD | WS_VISIBLE,m_wndSplitter.IdFromRowCol(0,1));
m_wndSplitterRight.CreateView(0,0,RUNTIME_CLASS(CRightTopView),paneSize,pContext);
m_wndSplitterRight.CreateView(1,0,RUNTIME_CLASS(CRightBttmView),paneSize,pContext);
return TRUE;
并包含SDIView.h、RightTopView.h、RightBttmView.h。编译,出现如下错误:
sdiview.h(16): error C2143: 语法错误 : 缺少“;”(在“*”的前面)
sdiview.h(16): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
sdiview.h(16): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
sdiview.h(16): warning C4183: “GetDocument”: 缺少返回类型;假定为返回“int”的成员函数