Share via


CSplitterWnd::Create

To create a dynamic splitter window, call the Create member function.

virtual BOOL Create( 
   CWnd* pParentWnd, 
   int nMaxRows, 
   int nMaxCols, 
   SIZE sizeMin, 
   CCreateContext* pContext, 
   DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | SPLS_DYNAMIC_SPLIT, 
   UINT nID = AFX_IDW_PANE_FIRST  
);

Parameters

  • pParentWnd
    The parent frame window of the splitter window.

  • nMaxRows
    The maximum number of rows in the splitter window. This value must not exceed 2.

  • nMaxCols
    The maximum number of columns in the splitter window. This value must not exceed 2.

  • sizeMin
    Specifies the minimum size at which a pane may be displayed.

  • pContext
    A pointer to a CCreateContext structure. In most cases, this can be the pContext passed to the parent frame window.

  • dwStyle
    Specifies the window style.

  • nID
    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 successful; otherwise 0.

Remarks

You can embed a CSplitterWnd in a parent CFrameWnd or CMDIChildWnd object by taking the following steps:

  1. Embed a CSplitterWnd member variable in the parent frame.

  2. Override the parent frame's CFrameWnd::OnCreateClient member function.

  3. Call the Create member function from within the overridden OnCreateClient.

When you create a splitter window from within a parent frame, pass the parent frame's pContext parameter to the splitter window. Otherwise, this parameter can be NULL.

The initial minimum row height and column width of a dynamic splitter window are set by the sizeMin parameter. These minimums, which determine whether a pane is too small to be shown in its entirety, can be changed with the SetRowInfo and SetColumnInfo member functions.

For more on dynamic splitter windows, see "Splitter Windows" in the article Multiple Document Types, Views, and Frame Windows, Technical Note 29, and the CSplitterWnd class overview.

Example

// the following function is created by the MFC Application Wizard  
// when you select Split window from the User Interface Features tab: 
BOOL CMyChildFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)
{
    return m_wndSplitter.Create(this,
        2, 2,       // TODO: adjust the number of rows, columns
        CSize(10, 10),  // TODO: adjust the minimum pane size
        pContext);
}

Requirements

Header: afxext.h

See Also

Reference

CSplitterWnd Class

Hierarchy Chart

CSplitterWnd::CreateStatic

CFrameWnd::OnCreateClient

CSplitterWnd::SetRowInfo

CSplitterWnd::SetColumnInfo

CSplitterWnd::CreateView