简单例子:
1. 在父框架中嵌入一个CSplitterWnd成员变量:
CSplitterWnd m_wndSplitter1;
CSplitterWnd m_wndSplitter2;
2. 重载父框架的CFrameWnd::OnCreateClient成员函数:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if(!(m_wndSplitter1.CreateStatic(this, 2, 1) ) ||
!(m_wndSplitter1.CreateView(1, 0, RUNTIME_CLASS(CMyListView), CSize(0,0), pContext) ) ||
!(m_wndSplitter2.CreateStatic(&m_wndSplitter1, 1, 2, WS_CHILD|WS_VISIBLE, m_wndSplitter1.IdFromRowCol(0,0)) ) ||
!(m_wndSplitter2.CreateView(0, 0, RUNTIME_CLASS(CMyTreeView), CSize(180 ,0), pContext) ) ||
!(m_wndSplitter2.CreateView(0, 1, RUNTIME_CLASS(CMyTextView), CSize(0,0), pContext) )
)
{
return FALSE;
}
m_wndSplitter1.SetRowInfo(0, 350, 0); //重新设置行宽
m_wndSplitter1.RecalcLayout();
return TRUE;
}
3.创建三个视图CMyListView、CMyTreeView、CMyTextView。
最后生成如下图所示: