动态分割窗口:
// TODO: Add your specialized code here and/or call the base class
if (m_WndSplitter.Create(this, 2, 2, CSize(10, 10), pContext))
{
return TRUE;
}
else
{
return false;
}
//return CFrameWnd::OnCreateClient(lpcs, pContext);
}
View Code
静态分割窗口:
为MainFrame类添加两个成员变量如下,并重载虚函数OnCreateClient,以实现窗口分割。
CSplitterWnd m_WndSplitter1;
CSplitterWnd m_WndSplitter2;
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
以CView为基类创建CView2,CView3,CView4类。
在MainFrame.cpp包含所有视图头文件
m_WndSplitter1.CreateView(0, 0, RUNTIME_CLASS(C窗口分割2View), CSize(100, 100), pContext); //连接0行0列窗格
m_WndSplitter1.CreateView(1, 0, RUNTIME_CLASS(CView2), CSize(100, 100), pContext); //用cview2连接1行0列窗格
//将两行0列再分开1行2列
if (!m_WndSplitter2.CreateStatic(&m_WndSplitter1, 1, 2, WS_CHILD | WS_VISIBLE, m_WndSplitter1.IdFromRowCol(2, 0)))
return FALSE;
m_WndSplitter2.CreateView(0, 0, RUNTIME_CLASS(CView3), CSize(400, 300), pContext); //用cview3连接到第二个分行对象0行0列窗格
m_WndSplitter2.CreateView(0, 1, RUNTIME_CLASS(CView4), CSize(400, 300), pContext); //用cview4连接到第二个分行对象0行1列窗格
return TRUE;
}