CSplitterWnd::CreateStatic
This method creates a static splitter window.
BOOL CreateStatic( CWnd* pParentWnd, int nRows, int nCols, DWORD dwStyle = WS_CHILD | WS_VISIBLE, UINT nID = AFX_IDW_PANE_FIRST );
Parameters
-
pParentWnd
- Specifies the parent frame window of the splitter window. nRows
- Specifies the number of rows. This value must not exceed 16. nCols
- Specifies the number of columns. This value must not exceed 16. dwStyle
- Specifies the window style. nID
- Specifies the child window ID of the window. The ID can be AFX_IDW_PANE_FIRST unless the splitter window is nested inside another splitter window.
Return Value
Nonzero if it is successful; otherwise, it is zero.
CSplitterWnd::CreateView
This method creates the panes for a static splitter window. All panes of a static splitter window must be created before the framework displays the splitter.
The framework also calls this method to create new panes when the user of a dynamic splitter window splits a pane, row, or column.
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 new view. col
- Specifies the splitter window column in which to place the new view. pViewClass
- Specifies the CRuntimeClass of the new view. sizeInit
- Specifies the initial size of the new view. pContext
- Specifies a pointer to a creation context used to create the view. This pointer is usually the pContext passed into the parent frame’s overridden CFrameWnd::OnCreateClient method in which the splitter window is being created.
Return Value
Nonzero if it is successful; otherwise, it is zero.
比如
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
split.CreateStatic(this,2,1);
split.CreateView(0,0,RUNTIME_CLASS(CTest3View),CSize(0,150),pContext);
split.CreateView(1,0,RUNTIME_CLASS(CTest3View),CSize(0,0),pContext);
return CMDIChildWnd::OnCreateClient(lpcs, pContext);
}

BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
split.CreateStatic(this,1,2);
split.CreateView(0,0,RUNTIME_CLASS(CTest3View),CSize(150,0),pContext);
split.CreateView(0,1,RUNTIME_CLASS(CTest3View),CSize(0,0),pContext);
return CMDIChildWnd::OnCreateClient(lpcs, pContext);
}

需要在theApp所在文件中的pDocTemplate项目制定为NULL
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_TEST3TYPE,
RUNTIME_CLASS(CTest3Doc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
NULL);
AddDocTemplate(pDocTemplate);