// The context information is passed on from the framework CCreateContext *pContext = (CCreateContext*)lpCreateStruct->lpCreateParams; if (!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(COutlookTreeView), CSize(150, 0), pContext)) { TRACE0("Failed to create COutlookTreeView\n"); return -1; } // add the third splitter pane - which is a nested splitter with 2 rows if (!m_wndSplitter2.CreateStatic(&m_wndSplitter, // our parent window is the first splitter 2, 1, // the new splitter is 2 rows, 1 column WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed m_wndSplitter.IdFromRowCol(0, 1))) // new splitter is in the first row, 3rd column of first splitter { TRACE0("Failed to create nested splitter\n"); return FALSE; } // now create the two views inside the nested splitter if (!m_wndSplitter2.CreateView(0, 0, RUNTIME_CLASS(COutlookListView), CSize(0, 150), pContext)) { TRACE0("Failed to create second pane\n"); return FALSE; } if (!m_wndSplitter2.CreateView(1, 0, RUNTIME_CLASS(COutlookDescView), CSize(0, 0), pContext)) { TRACE0("Failed to create third pane\n"); return FALSE; }
s1.CreateStatic(this,2,1);
s2.CreateStatic(&s1,1,2,WS_CHILD|WS_VISIBLE,s1.IdFromRowCol(0,0));
s2.CreateView(0,0,……);
s2.CreateView(0,1,……);
s1.CreateView(1,0,……);
// The context information is passed on from the framework
CCreateContext *pContext = (CCreateContext*)lpCreateStruct->lpCreateParams; if (!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(COutlookTreeView),
CSize(150, 0), pContext))
{
TRACE0("Failed to create COutlookTreeView\n");
return -1;
} // add the third splitter pane - which is a nested splitter with 2 rows
if (!m_wndSplitter2.CreateStatic(&m_wndSplitter, // our parent window is the first splitter
2, 1, // the new splitter is 2 rows, 1 column
WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed
m_wndSplitter.IdFromRowCol(0, 1))) // new splitter is in the first row, 3rd column of first splitter
{
TRACE0("Failed to create nested splitter\n");
return FALSE;
} // now create the two views inside the nested splitter
if (!m_wndSplitter2.CreateView(0, 0,
RUNTIME_CLASS(COutlookListView), CSize(0, 150), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
} if (!m_wndSplitter2.CreateView(1, 0,
RUNTIME_CLASS(COutlookDescView), CSize(0, 0), pContext))
{
TRACE0("Failed to create third pane\n");
return FALSE;
}
你可以在MSDN中看看以下函数:
CSplitterWnd::CreateStatic()
CSplitterWnd::CreateView()
如果只需要拆第一行,可以把第一行看作第二个CSplitterWnd对象进行拆分。
m_wndSp.CreateStatic(this, 2, 1); //创建二行一列的拆分
m_wndSp1.CreateStatic(&m_wndSp, 1, 2);//创建一行两列的拆分//SOMEVIEW_1
m_wndSp.CreateView(1, 0,
RUNTIME_CLASS(SOMEVIEW_1),
CSize(200,200), pContext);
//SOMEVIEW_0_0
m_wndSp1.CreateView(0, 0,
RUNTIME_CLASS(SOMEVIEW_0_0),
CSize(100,50), pContext);
//SOMEVIEW_0_1
m_wndSp1.CreateView(0, 1,
RUNTIME_CLASS(SOMEVIEW_0_1),
CSize(100,50), pContext);SetActiveView((CView*)m_wndSp.GetPane(0, 0));
m_wndSp1.CreateStatic(
&m_wndSp, 1, 2,
WS_CHILD | WS_VISIBLE, m_wndSp.IdFromRowCol(0,0));
//创建一行两列的拆分