单文档 多视图的实现

我想要的界面如下:

单文档 多视图的实现_第1张图片

 

分割策略:先分为两行一列,再对第一行分为四列,第二行分为三列。一共分割三次。

实现:

定义三个分割变量,并在MainFrm.h中添加:

CSplitterWnd m_wndSplitter; CSplitterWnd m_wndSplitter1; CSplitterWnd m_wndSplitter2;

添加视图类:两个CFormView类:CLControl,CRControl。四个View类:COScene,CIScene,CLVideo,CRVideo。

一个CListView类:CLog。

在MainFrm.h文件中添加函数OnCreateClient,位置如下:

// Overrides public: virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);//66666

并实现该函数,代码如下:

 

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext *pContext) //用于视图分割添加的,包括CViewLeft类 { //第一次分割,两行一列 if(m_wndSplitter.CreateStatic(this,2,1)==NULL) return FALSE; //第二次分割,将第一行分为四列,并将每列对应上视图 m_wndSplitter1.CreateStatic(&m_wndSplitter,1,4,WS_CHILD|WS_VISIBLE,m_wndSplitter.IdFromRowCol(0,0)); m_wndSplitter1.CreateView(0,0,RUNTIME_CLASS(CLControl),CSize(0,0),pContext); m_wndSplitter1.CreateView(0,1,RUNTIME_CLASS(COScene),CSize(0,0),pContext); m_wndSplitter1.CreateView(0,2,RUNTIME_CLASS(CIScene),CSize(0,0),pContext); m_wndSplitter1.CreateView(0,3,RUNTIME_CLASS(CRControl),CSize(0,0),pContext); //第三次分割,将第二行分为三列,并将每列对应上视图 m_wndSplitter2.CreateStatic(&m_wndSplitter,1,3,WS_CHILD|WS_VISIBLE,m_wndSplitter.IdFromRowCol(1,0)); m_wndSplitter2.CreateView(0,0,RUNTIME_CLASS(CLVideo),CSize(0,0),pContext); m_wndSplitter2.CreateView(0,1,RUNTIME_CLASS(CLog),CSize(0,0),pContext); m_wndSplitter2.CreateView(0,2,RUNTIME_CLASS(CRVideo),CSize(0,0),pContext); //下面语句设置每行每列的长宽 m_wndSplitter.SetColumnInfo(0, 100,50); m_wndSplitter.SetRowInfo(0, 100,50); m_wndSplitter.SetRowInfo(1, 100,50); m_wndSplitter.RecalcLayout(); m_wndSplitter1.SetColumnInfo(0, 100,50); m_wndSplitter1.SetColumnInfo(1, 100,50); m_wndSplitter1.SetColumnInfo(2, 100,50); m_wndSplitter1.SetColumnInfo(3, 100,50); m_wndSplitter1.SetRowInfo(0, 100,50); m_wndSplitter1.RecalcLayout(); m_wndSplitter2.SetColumnInfo(0, 100,50); m_wndSplitter2.SetColumnInfo(1, 100,50); m_wndSplitter2.SetColumnInfo(2, 100,50); m_wndSplitter2.SetRowInfo(0, 100,50); m_wndSplitter2.RecalcLayout(); return TRUE; }

 

这样就可以实现上面的框架界面了。呵呵。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(框架,null,Class,文档)