建立单文档多视图

学习MFC,建立在CMainFRame中建立多视图,三个视图。

 单文档多视图

1.先建立三个类,CLeftView继承了CTreeView类,CRightView继承了CListView类,CBottomView继承了CView类。

2.先把三个的h文件都包含在CMainFrame中,然后建立2个 CSplitterWnd对象

一个是m_lwndSplitter,另一个是m_rwndSplitter;

3.建立虚函数OnCreateClient,在代码里写入如下代码。

其中先建立左右分割窗口,再建立右边的上下窗口。

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{

 VERIFY(m_lwndSplitter.CreateStatic(this,1,2));
    VERIFY(m_lwndSplitter.CreateView(0,0,RUNTIME_CLASS(CLeftView),CSize(180,550),pContext));
    VERIFY(m_rwndSplitter.CreateStatic(&m_lwndSplitter,2,1,WS_CHILD|WS_VISIBLE,m_lwndSplitter.IdFromRowCol(0,1)));
 VERIFY(m_rwndSplitter.CreateView(0,0,RUNTIME_CLASS(CRightView),CSize(100,450),pContext));
 VERIFY(m_rwndSplitter.CreateView(1,0,RUNTIME_CLASS(CBottomView),CSize(100,100),pContext));
    //return TRUE;
 return CFrameWnd::OnCreateClient(lpcs, pContext);
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章