To create a static splitter window, call the CreateStaticmember function.
virtual BOOL CreateStatic( CWnd* pParentWnd, int nRows, int nCols, DWORD dwStyle = WS_CHILD | WS_VISIBLE, UINT nID = AFX_IDW_PANE_FIRST );
Parameters
-
pParentWnd
-
The parent frame window of the splitter window.
-
nRows
-
The number of rows. This value must not exceed 16.
-
nCols
-
The number of columns. This value must not exceed 16.
-
dwStyle
-
Specifies the window style.
-
nID
-
The child window ID of the window. The ID can beAFX_IDW_PANE_FIRST unless the splitter window is nestedinside another splitter window.
(2)CSplitterWnd::CreateView
Creates the panes for a static splitter window.
virtual BOOL CreateView( int row, int col, CRuntimeClass* pViewClass, SIZE sizeInit, CCreateContext* pContext );
Parameters
-
row
-
Specifies the splitter window row in which to place the newview.
-
col
-
Specifies the splitter window column in which to place the newview.
-
pViewClass
-
Specifies the CRuntimeClassof the new view.
-
sizeInit
-
Specifies the initial size of the new view.
-
pContext
-
A pointer to a creation context used to create the view (usuallythe pContext passed into the parentframe's overridden CFrameWnd::OnCreateClientmember function in which the splitter window is being created).
All panes of a static splitter window must be created before theframework displays the splitter.
The framework also calls this member function to create newpanes when the user of a dynamic splitter window splits a pane,row, or column.
二、(1)OnCreateClient绘制与文档对象和边框窗口对象相联系的视区。
(2)在单个视类的切分窗口中,各个视区的内容是完全一致的,只要一个视类对象
(3)切分窗口为多视类则,不同的切分窗口可以显示不同的内容,因此要创建多个视类对象。
三、代码:
(1)声明切分窗口(可能要)
CChildFrame类中加入 CSpliterWnd m_wndSplitter
(2)在OnCreateClient加入代码
// this function creates the panes for a static splitter windowBOOL CChildFrame::OnCreateClient( LPCREATESTRUCT lpcs, CCreateContext* pContext){ BOOL bCreateSpltr = m_wndSplitter.CreateStatic( this, 2, 1); // COneView and CAnotherView are user-defined views derived from CMDIView m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(COneView), CSize(0,0), pContext); m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CAnotherView), CSize(0,0), pContext); return (bCreateSpltr);}