1.首先在CMainFrm.h中定义2个CSplitterWnd 的变量:
CSplitterWnd m_wndSplitter1;
CSplitterWnd m_wndSplitter2;
2.添加你要加载的3个子窗口的类class wizard ----add class-----新建基于cview的类CView1,CView2,CView3。
3.在CMainFrm.CPp中添加消息响应函数OnCreateClient。
4.
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
#define INFO_VIEW_HEIGHT 200
// TODO: Add your specialized code here and/or call the base class
// create a splitter with 2 row, 1 columns
if (!m_wndSplitter1.CreateStatic(this, 2, 1))
{
TRACE0("Failed to CreateStaticSplitter/n");
return FALSE;
}
int row = 500;
m_wndSplitter1.SetRowInfo(0, row, 64);
m_wndSplitter1.SetRowInfo(1, INFO_VIEW_HEIGHT, 64);
// add the first splitter pane
// which is a nested splitter with 2 columns
if (!m_wndSplitter2.CreateStatic(
&m_wndSplitter1, // our parent window is the first splitter
1, 2, // the new splitter is 2 rows, 1 column
WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed
m_wndSplitter1.IdFromRowCol(0, 0)
// new splitter is in the first row, 2nd column of first splitter
))
{
TRACE0("Failed to create nested splitter/n");
return FALSE;
}
int column = 200;
m_wndSplitter2.SetColumnInfo(0, column, 64);
m_wndSplitter2.SetColumnInfo(1, column, 64);
// now create the two views inside the nested splitter
if (!m_wndSplitter2.CreateView(0, 0,
RUNTIME_CLASS(CView1), CSize(column, row), pContext))
{
TRACE0("Failed to create Tree pane/n");
return FALSE;
}
if (!m_wndSplitter2.CreateView(0, 1,
RUNTIME_CLASS(CView2), CSize(column, row), pContext))
{
TRACE0("Failed to create Edit pane/n");
return FALSE;
}
if (!m_wndSplitter1.CreateView(1, 0,
RUNTIME_CLASS(CView4), CSize(column, row), pContext))
{
TRACE0("Failed to create Edit pane/n");
return FALSE;
}
return TRUE;
}
即可生成上面2列,下面1列的三叉窗口界面!!