Udostępnij za pośrednictwem


CSplitterWnd Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CSplitterWnd Class.

Provides the functionality of a splitter window, which is a window that contains multiple panes.

Syntax

class CSplitterWnd : public CWnd  

Members

Public Constructors

Name Description
CSplitterWnd::CSplitterWnd Call to construct a CSplitterWnd object.

Public Methods

Name Description
CSplitterWnd::ActivateNext Performs the Next Pane or Previous Pane command.
CSplitterWnd::CanActivateNext Checks to see if the Next Pane or Previous Pane command is currently possible.
CSplitterWnd::Create Call to create a dynamic splitter window and attach it to the CSplitterWnd object.
CSplitterWnd::CreateScrollBarCtrl Creates a shared scroll bar control.
CSplitterWnd::CreateStatic Call to create a static splitter window and attach it to the CSplitterWnd object.
CSplitterWnd::CreateView Call to create a pane in a splitter window.
CSplitterWnd::DeleteColumn Deletes a column from the splitter window.
CSplitterWnd::DeleteRow Deletes a row from the splitter window.
CSplitterWnd::DeleteView Deletes a view from the splitter window.
CSplitterWnd::DoKeyboardSplit Performs the keyboard split command, usually "Window Split."
CSplitterWnd::DoScroll Performs synchronized scrolling of split windows.
CSplitterWnd::DoScrollBy Scrolls split windows by a given number of pixels.
CSplitterWnd::GetActivePane Determines the active pane from the focus or active view in the frame.
CSplitterWnd::GetColumnCount Returns the current pane column count.
CSplitterWnd::GetColumnInfo Returns information on the specified column.
CSplitterWnd::GetPane Returns the pane at the specified row and column.
CSplitterWnd::GetRowCount Returns the current pane row count.
CSplitterWnd::GetRowInfo Returns information on the specified row.
CSplitterWnd::GetScrollStyle Returns the shared scroll-bar style.
CSplitterWnd::IdFromRowCol Returns the child window ID of the pane at the specified row and column.
CSplitterWnd::IsChildPane Call to determine whether the window is currently a child pane of this splitter window.
CSplitterWnd::IsTracking Determines if splitter bar is currently being moved.
CSplitterWnd::RecalcLayout Call to redisplay the splitter window after adjusting row or column size.
CSplitterWnd::SetActivePane Sets a pane to be the active one in the frame.
CSplitterWnd::SetColumnInfo Call to set the specified column information.
CSplitterWnd::SetRowInfo Call to set the specified row information.
CSplitterWnd::SetScrollStyle Specifies the new scroll-bar style for the splitter window's shared scroll-bar support.
CSplitterWnd::SplitColumn Indicates where a frame window splits vertically.
CSplitterWnd::SplitRow Indicates where a frame window splits horizontally.

Protected Methods

Name Description
CSplitterWnd::OnDraw Called by the framework to draw the splitter window.
CSplitterWnd::OnDrawSplitter Renders an image of a split window.
CSplitterWnd::OnInvertTracker Renders the image of a split window to be the same size and shape as the frame window.

Remarks

A pane is usually an application-specific object derived from CView, but it can be any CWnd object that has the appropriate child window ID.

A CSplitterWnd object is usually embedded in a parent CFrameWnd or CMDIChildWnd object. Create a CSplitterWnd object using the following steps:

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

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

  3. From within the overridden OnCreateClient, call the Create or CreateStatic member function of CSplitterWnd.

Call the Create member function to create a dynamic splitter window. A dynamic splitter window typically is used to create and scroll a number of individual panes, or views, of the same document. The framework automatically creates an initial pane for the splitter; then the framework creates, resizes, and disposes of additional panes as the user operates the splitter window's controls.

When you call Create, you specify a minimum row height and column width that determine when the panes are too small to be fully displayed. After you call Create, you can adjust these minimums by calling the SetColumnInfo and SetRowInfo member functions.

Also use the SetColumnInfo and SetRowInfo member functions to set an "ideal" width for a column and "ideal" height for a row. When the framework displays a splitter window, it first displays the parent frame, then the splitter window. The framework then lays out the panes in columns and rows according to their ideal dimensions, working from the upper-left to the lower-right corner of the splitter window's client area.

All panes in a dynamic splitter window must be of the same class. Familiar applications that support dynamic splitter windows include Microsoft Word and Microsoft Excel.

Use the CreateStatic member function to create a static splitter window. The user can change only the size of the panes in a static splitter window, not their number or order.

You must specifically create all the static splitter's panes when you create the static splitter. Make sure you create all the panes before the parent frame's OnCreateClient member function returns, or the framework will not display the window correctly.

The CreateStatic member function automatically initializes a static splitter with a minimum row height and column width of 0. After you call Create, adjust these minimums by calling the SetColumnInfo and SetRowInfo member functions. Also use SetColumnInfo and SetRowInfo after you call CreateStatic to indicate desired ideal pane dimensions.

The individual panes of a static splitter often belong to different classes. For examples of static splitter windows, see the graphics editor and the Windows File Manager.

A splitter window supports special scroll bars (apart from the scroll bars that panes may have). These scroll bars are children of the CSplitterWnd object and are shared with the panes.

You create these special scroll bars when you create the splitter window. For example, a CSplitterWnd that has one row, two columns, and the WS_VSCROLL style will display a vertical scroll bar that is shared by the two panes. When the user moves the scroll bar, WM_VSCROLL messages are sent to both panes. When the panes set the scroll-bar position, the shared scroll bar is set.

For further information on splitter windows, see:

  • Technical Note 29

  • Knowledge Base article Q262024: HOWTO: Use CPropertySheet as a Child of CSplitterWnd

For more information on how to create dynamic splitter windows, see:

Inheritance Hierarchy

CObject

CCmdTarget

CWnd

CSplitterWnd

Requirements

Header: afxext.h

CSplitterWnd::ActivateNext

Called by the framework to perform the Next Pane or Previous Pane command.

virtual void ActivateNext(BOOL bPrev = FALSE);

Parameters

bPrev
Indicates which window to activate. TRUE for previous; FALSE for next.

Remarks

This member function is a high level command that is used by the CView class to delegate to the CSplitterWnd implementation.

CSplitterWnd::CanActivateNext

Called by the framework to check to see if the Next Pane or Previous Pane command is currently possible.

virtual BOOL CanActivateNext(BOOL bPrev = FALSE);

Parameters

bPrev
Indicates which window to activate. TRUE for previous; FALSE for next.

Return Value

Nonzero if successful; otherwise 0.

Remarks

This member function is a high level command that is used by the CView class to delegate to the CSplitterWnd implementation.

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);
}

CSplitterWnd::CreateScrollBarCtrl

Called by the framework to create a shared scroll bar control.

virtual BOOL CreateScrollBarCtrl(
    DWORD dwStyle,  
    UINT nID);

Parameters

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

Override CreateScrollBarCtrl to include extra controls next to a scroll bar. The default behavior is to create normal Windows scroll bar controls.

CSplitterWnd::CreateStatic

To create a static splitter window, call the CreateStatic member 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 be AFX_IDW_PANE_FIRST unless the splitter window is nested inside another splitter window.

Return Value

Nonzero if successful; otherwise 0.

Remarks

A CSplitterWnd is usually embedded 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 OnCreateClient member function.

  3. Call the CreateStatic member function from within the overridden CFrameWnd::OnCreateClient.

A static splitter window contains a fixed number of panes, often from different classes.

When you create a static splitter window, you must at the same time create all its panes. The CreateView member function is usually used for this purpose, but you can create other nonview classes as well.

The initial minimum row height and column width for a static splitter window is 0. These minimums, which determine when a pane is too small to be shown in its entirety, can be changed with the SetRowInfo and SetColumnInfo member functions.

To add scroll bars to a static splitter window, add the WS_HSCROLL and WS_VSCROLL styles to dwStyle.

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

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 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
A pointer to a creation context used to create the view (usually the pContext passed into the parent frame's overridden CFrameWnd::OnCreateClient member function in which the splitter window is being created).

Return Value

Nonzero if successful; otherwise 0.

Remarks

All panes of a static splitter window must be created before the framework displays the splitter.

The framework also calls this member function to create new panes when the user of a dynamic splitter window splits a pane, row, or column.

Example

// this function creates the panes for a static splitter window
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)
{
   m_bSplitterCreated = m_wndSplitter.CreateStatic(this, 1, 2);
   // CMyView and CMyOtherView are user-defined views derived from CView
   m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CMyView), CSize(0, 0), 
      pContext);
   m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CMyOtherView), CSize(0, 0), 
      pContext);

   return (m_bSplitterCreated);
}

CSplitterWnd::CSplitterWnd

Call to construct a CSplitterWnd object.

CSplitterWnd();

Remarks

Construct a CSplitterWnd object in two steps. First, call the constructor, which creates the CSplitterWnd object, and then call the Create member function, which creates the splitter window and attaches it to the CSplitterWnd object.

CSplitterWnd::DeleteColumn

Deletes a column from the splitter window.

virtual void DeleteColumn(int colDelete);

Parameters

colDelete
Specifies the column to be deleted.

Remarks

This member function is called by the framework to implement the logic of the dynamic splitter window (that is, if the splitter window has the SPLS_DYNAMIC_SPLIT style). It can be customized, along with the virtual function CreateView, to implement more advanced dynamic splitters.

CSplitterWnd::DeleteRow

Deletes a row from the splitter window.

virtual void DeleteRow(int rowDelete);

Parameters

rowDelete
Specifies the row to be deleted.

Remarks

This member function is called by the framework to implement the logic of the dynamic splitter window (that is, if the splitter window has the SPLS_DYNAMIC_SPLIT style). It can be customized, along with the virtual function CreateView, to implement more advanced dynamic splitters.

CSplitterWnd::DeleteView

Deletes a view from the splitter window.

virtual void DeleteView(
    int row,  
    int col);

Parameters

row
Specifies the splitter window row at which to delete the view.

col
Specifies the splitter window column at which to delete the view.

Remarks

If the active view is being deleted, the next view will become active. The default implementation assumes the view will auto delete in PostNcDestroy.

This member function is called by the framework to implement the logic of the dynamic splitter window (that is, if the splitter window has the SPLS_DYNAMIC_SPLIT style). It can be customized, along with the virtual function CreateView, to implement more advanced dynamic splitters.

CSplitterWnd::DoKeyboardSplit

Performs the keyboard split command, usually "Window Split."

virtual BOOL DoKeyboardSplit();

Return Value

Nonzero if successful; otherwise 0.

Remarks

This member function is a high level command that is used by the CView class to delegate to the CSplitterWnd implementation.

CSplitterWnd::DoScroll

Performs synchronized scrolling of split windows.

virtual BOOL DoScroll(
    CView* pViewFrom,  
    UINT nScrollCode,  
    BOOL bDoScroll = TRUE);

Parameters

pViewFrom
A pointer to the view from which the scrolling message originates.

nScrollCode
A scroll-bar code that indicates the user's scrolling request. This parameter is composed of two parts: a low-order byte, which determines the type of scrolling occurring horizontally, and a high-order byte, which determines the type of scrolling occurring vertically:

  • SB_BOTTOM Scrolls to bottom.

  • SB_LINEDOWN Scrolls one line down.

  • SB_LINEUP Scrolls one line up.

  • SB_PAGEDOWN Scrolls one page down.

  • SB_PAGEUP Scrolls one page up.

  • SB_TOP Scrolls to top.

bDoScroll
Determines whether the specified scrolling action occurs. If bDoScroll is TRUE (that is, if a child window exists, and if the split windows have a scroll range), then the specified scrolling action can take place; if bDoScroll is FALSE (that is, if no child window exists, or the split views have no scroll range), then scrolling does not occur.

Return Value

Nonzero if synchronized scrolling occurs; otherwise 0.

Remarks

This member function is called by the framework to perform synchronized scrolling of split windows when the view receives a scroll message. Override to require an action by the user before synchronized scrolling is allowed.

CSplitterWnd::DoScrollBy

Scrolls split windows by a given number of pixels.

virtual BOOL DoScrollBy(
    CView* pViewFrom,  
    CSize sizeScroll,  
    BOOL bDoScroll = TRUE);

Parameters

pViewFrom
A pointer to the view from which the scrolling message originates.

sizeScroll
Number of pixels to be scrolled horizontally and vertically.

bDoScroll
Determines whether the specified scrolling action occurs. If bDoScroll is TRUE (that is, if a child window exists, and if the split windows have a scroll range), then the specified scrolling action can take place; if bDoScroll is FALSE (that is, if no child window exists, or the split views have no scroll range), then scrolling does not occur.

Return Value

Nonzero if synchronized scrolling occurs; otherwise 0.

Remarks

This member function is called by the framework in response to a scroll message, to perform synchronized scrolling of the split windows by the amount, in pixels, indicated by sizeScroll. Positive values indicate scrolling down and to the right; negative values indicate scrolling up and to the left.

Override to require an action by the user before allowing scroll.

CSplitterWnd::GetActivePane

Determines the active pane from the focus or active view in the frame.

virtual CWnd* GetActivePane(
    int* pRow = NULL,  
    int* pCol = NULL);

Parameters

pRow
A pointer to an int to retrieve the row number of the active pane.

pCol
A pointer to an int to retrieve the column number of the active pane.

Return Value

Pointer to the active pane. NULL if no active pane exists.

Remarks

This member function is called by the framework to determine the active pane in a splitter window. Override to require an action by the user before getting the active pane.

CSplitterWnd::GetColumnCount

Returns the current pane column count.

int GetColumnCount() const;  

Return Value

Returns the current number of columns in the splitter. For a static splitter, this will also be the maximum number of columns.

CSplitterWnd::GetColumnInfo

Returns information on the specified column.

void GetColumnInfo(
    int col,  
    int& cxCur,  
    int& cxMin) const;  

Parameters

col
Specifies a column.

cxCur
A reference to an int to be set to the current width of the column.

cxMin
A reference to an int to be set to the current minimum width of the column.

CSplitterWnd::GetPane

Returns the pane at the specified row and column.

CWnd* GetPane(
    int row,  
    int col) const;  

Parameters

row
Specifies a row.

col
Specifies a column.

Return Value

Returns the pane at the specified row and column. The returned pane is usually a CView-derived class.

CSplitterWnd::GetRowCount

Returns the current pane row count.

int GetRowCount() const;  

Return Value

Returns the current number of rows in the splitter window. For a static splitter window, this will also be the maximum number of rows.

CSplitterWnd::GetRowInfo

Returns information on the specified row.

void GetRowInfo(
    int row,  
    int& cyCur,  
    int& cyMin) const;  

Parameters

row
Specifies a row.

cyCur
Reference to int to be set to the current height of the row in pixels.

cyMin
Reference to int to be set to the current minimum height of the row in pixels.

Remarks

Call this member function to obtain information about the specified row. The cyCur parameter is filled with the current height of the specified row, and cyMin is filled with the minimum height of the row.

CSplitterWnd::GetScrollStyle

Returns the shared scroll-bar style for the splitter window.

DWORD GetScrollStyle() const;  

Return Value

One or more of the following windows style flags, if successful:

  • WS_HSCROLL If the splitter currently manages shared horizontal scroll bars.

  • WS_VSCROLL If the splitter currently manages shared vertical scroll bars.

If zero, the splitter window does not currently manage any shared scroll bars.

CSplitterWnd::IdFromRowCol

Obtains the child window ID for the pane at the specified row and column.

int IdFromRowCol(
    int row,  
    int col) const;  

Parameters

row
Specifies the splitter window row.

col
Specifies the splitter window column.

Return Value

The child window ID for the pane.

Remarks

This member function is used for creating nonviews as panes and may be called before the pane exists.

Example

HBRUSH CMySplitterWnd::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
   HBRUSH hbr = CSplitterWnd::OnCtlColor(pDC, pWnd, nCtlColor);
   
   if(nCtlColor == CTLCOLOR_LISTBOX && 
      pWnd->GetDlgCtrlID() == IdFromRowCol(1,0))
   {
      // Pane 1,0 is a list box. Set the color of the text to be blue.
      pDC->SetBkColor(m_BkColor);
      pDC->SetTextColor(RGB(0,0,255));
      return (HBRUSH)m_hbrListBoxBkgnd.GetSafeHandle();
   }
   // TODO: Return a different brush if the default is not desired
   return hbr;
}

CSplitterWnd::IsChildPane

Determines whether pWnd is currently a child pane of this splitter window.

BOOL IsChildPane(
    CWnd* pWnd,  
    int* pRow,  
    int* pCol);

Parameters

pWnd
A pointer to a CWnd object to be tested.

pRow
A pointer to an int in which to store row number.

pCol
A pointer to an int in which to store a column number.

Return Value

If nonzero, pWnd is currently a child pane of this splitter window, and pRow and pCol are filled in with the position of the pane in the splitter window. If pWnd is not a child pane of this splitter window, 0 is returned.

Remarks

In Visual C++ versions prior to 6.0, this function was defined as

BOOL IsChildPane(CWnd* pWnd, int& row, int& col);

This version is now obsolete and should not be used.

CSplitterWnd::IsTracking

Call this member function to determine if the splitter bar in the window is currently being moved.

BOOL IsTracking();

Return Value

Nonzero if a splitter operation is in progress; otherwise 0.

CSplitterWnd::OnDrawSplitter

Renders an image of a split window.

virtual void OnDrawSplitter(
    CDC* pDC,  
    ESplitType nType,  
    const CRect& rect);

Parameters

pDC
A pointer to the device context in which to draw. If pDC is NULL, then CWnd::RedrawWindow is called by the framework and no split window is drawn.

nType
A value of the enum ESplitType, which can be one of the following:

  • splitBox The splitter drag box.

  • splitBar The bar that appears between the two split windows.

  • splitIntersection The intersection of the split windows. This element will not be called when running on Windows 95/98.

  • splitBorder The split window borders.

rect
A reference to a CRect object specifying the size and shape of the split windows.

Remarks

This member function is called by the framework to draw and specify the exact characteristics of a splitter window. Override OnDrawSplitter for advanced customization of the imagery for the various graphical components of a splitter window. The default imagery is similar to the splitter in Microsoft Works for Windows or Microsoft Windows 95/98, in that the intersections of the splitter bars are blended together.

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.

CSplitterWnd::OnInvertTracker

Renders the image of a split window to be the same size and shape as the frame window.

virtual void OnInvertTracker(const CRect& rect);

Parameters

rect
Reference to a CRect object specifying the tracking rectangle.

Remarks

This member function is called by the framework during resizing of splitters. Override OnInvertTracker for advanced customization of the imagery of the splitter window. The default imagery is similar to the splitter in Microsoft Works for Windows or Microsoft Windows 95/98, in that the intersections of the splitter bars are blended together.

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.

CSplitterWnd::RecalcLayout

Call to redisplay the splitter window after adjusting row or column size.

virtual void RecalcLayout();

Remarks

Call this member function to correctly redisplay the splitter window after you have adjusted row and column sizes with the SetRowInfo and SetColumnInfo member functions. If you change row and column sizes as part of the creation process before the splitter window is visible, it is not necessary to call this member function.

The framework calls this member function whenever the user resizes the splitter window or moves a split.

Example

See the example for CSplitterWnd::SetColumnInfo.

CSplitterWnd::SetActivePane

Sets a pane to be the active one in the frame.

virtual void SetActivePane(
    int row,  
    int col,  
    CWnd* pWnd = NULL);

Parameters

row
If pWnd is NULL, specifies the row in the pane that will be active.

col
If pWnd is NULL, specifies the column in the pane that will be active.

pWnd
A pointer to a CWnd object. If NULL, the pane specified by row and col is set active. If not NULL, specifies the pane that is set active.

Remarks

This member function is called by the framework to set a pane as active when the user changes the focus to a pane within the frame window. You can explicitly call SetActivePane to change the focus to the specified view.

Specify pane by providing either row and column, or by providing pWnd.

CSplitterWnd::SetColumnInfo

Call to set the specified column information.

void SetColumnInfo(
    int col,  
    int cxIdeal,  
    int cxMin);

Parameters

col
Specifies a splitter window column.

cxIdeal
Specifies an ideal width for the splitter window column in pixels.

cxMin
Specifies a minimum width for the splitter window column in pixels.

Remarks

Call this member function to set a new minimum width and ideal width for a column. The column minimum value determines when the column will be too small to be fully displayed.

When the framework displays the splitter window, it lays out the panes in columns and rows according to their ideal dimensions, working from the upper-left to the lower-right corner of the splitter window's client area.

Example

void CChildFrame::OnSize(UINT nType, int cx, int cy) 
{
   CMDIChildWnd::OnSize(nType, cx, cy);

   CRect rect;
   GetWindowRect(&rect);
   if(m_bSplitterCreated)  // m_bSplitterCreated set in OnCreateClient
   {
      m_wndSplitter.SetColumnInfo(0, rect.Width()/2, 10);
      m_wndSplitter.SetColumnInfo(1, rect.Width()/2, 10);
      m_wndSplitter.RecalcLayout();
   }
}

CSplitterWnd::SetRowInfo

Call to set the specified row information.

void SetRowInfo(
    int row,  
    int cyIdeal,  
    int cyMin);

Parameters

row
Specifies a splitter window row.

cyIdeal
Specifies an ideal height for the splitter window row in pixels.

cyMin
Specifies a minimum height for the splitter window row in pixels.

Remarks

Call this member function to set a new minimum height and ideal height for a row. The row minimum value determines when the row will be too small to be fully displayed.

When the framework displays the splitter window, it lays out the panes in columns and rows according to their ideal dimensions, working from the upper-left to the lower-right corner of the splitter window's client area.

CSplitterWnd::SetScrollStyle

Specifies the new scroll style for the splitter window's shared scroll-bar support.

void SetScrollStyle(DWORD dwStyle);

Parameters

dwStyle
The new scroll style for the splitter window's shared scroll-bar support, which can be one of the following values:

  • WS_HSCROLL Create/show horizontal shared scroll bars.

  • WS_VSCROLL Create/show vertical shared scroll bars.

Remarks

Once a scroll bar is created it will not be destroyed even if SetScrollStyle is called without that style; instead those scroll bars are hidden. This allows the scroll bars to retain their state even though they are hidden. After calling SetScrollStyle it is necessary to call RecalcLayout for all the changes to take effect.

CSplitterWnd::SplitColumn

Indicates where a frame window splits vertically.

virtual BOOL SplitColumn(int cxBefore);

Parameters

cxBefore
The position, in pixels, before which the split occurs.

Return Value

Nonzero if successful; otherwise 0.

Remarks

This member function is called when a vertical splitter window is created. SplitColumn indicates the default location where the split occurs.

SplitColumn is called by the framework to implement the logic of the dynamic splitter window (that is, if the splitter window has the SPLS_DYNAMIC_SPLIT style). It can be customized, along with the virtual function CreateView, to implement more advanced dynamic splitters.

CSplitterWnd::SplitRow

Indicates where a frame window splits horizontally.

virtual BOOL SplitRow(int cyBefore);

Parameters

cyBefore
The position, in pixels, before which the split occurs.

Return Value

Nonzero if successful; otherwise 0.

Remarks

This member function is called when a horizontal splitter window is created. SplitRow indicates the default location where the split occurs.

SplitRow is called by the framework to implement the logic of the dynamic splitter window (that is, if the splitter window has the SPLS_DYNAMIC_SPLIT style). It can be customized, along with the virtual function CreateView, to implement more advanced dynamic splitters.

CSplitterWnd::OnDraw

Called by the framework to draw the splitter window.

virtual void OnDraw(CDC* pDC);

Parameters

pDC
A pointer to a device context.

Remarks

See Also

MFC Sample VIEWEX
CWnd Class
Hierarchy Chart
CView Class
CWnd Class