MFC split form (Splitter Windows)
<Reference msdn Microsoft Foundation Class Library and templates TNO 029>
This document describes the csplitterwnd class in MFC, which is used to support form separation and Management of the size of each sub-pane (PANE) after split.
1. Splitter Styles)
The csplitterwnd class supports split windows of two different styles.
1.1 static splitter)
The split pane is created when the split form (splitter window;) is created, and the order and quantity remain unchanged. The split control bar is used to control the size of each pane. normally, different panes are different view classes );
For example, Visual C ++ graphics and Windows File Manager are separated forms in this style;
This style split form does not use splitter box)
1.2 dynamic split)
When a user controls the splitting or stop splitting of a view, the additional pane is created or destroyed. This Dynamic Splitting starts from a separate view and is used to initialize the splitting; when a view can be split in two directions, three new views are created and displayed as three new panes. When a split is active) the splitter box is drawn in the same way as the splitter bar. When a user removes the splitter bar, the additional pane is destroyed, only the original view (the pane at the position of 0 rows and 0 columns when split) will be retained until the split form itself is destroyed;
For example, Microsoft Excel and Microsoft Word are separated in this style;
When creating a split form of any style, you must specify the maximum number of rows and columns of the split form;
Static style split form, each pane must be created csplitterwnd: createview;
The first pane of the dynamic split form is automatically created in the csplitterwnd object creation.
The maximum number of columns in a static split form is 16x16.
The maximum number of columns in a dynamic split form is 2x2.
The recommended splitting method is:
1x2 2x1 2x2
2. Example of splitting a form (Splitter Samples)
Many column subprograms of MFC use the Dynamic Splitting form directly or indirectly in section 4th of the segmentation form MFC Entry Program scripple program.
In the Standard MFC example, viewex shows how to use a split form statically, including how to include another split form in one split form
3. Terminology Used By Implement)
CsplitterWnd (split form ):
Provides the pane split space and the scroll bar (ROW) share the vertical scrollbar), and the horizontal scroll bar (horizontal scrollbar) for the same column. At the same time, the subscript of the row and column is from 0, start from 0, that is, the first window is the pane of 0th columns in 0th rows
Pane (Pane)
Applications managed by csplitterwnd display data forms. In general, the pane is a derived class object of a view. In fact, the pane can be any object derived from cwnd;
Splitter Bar (split control Bar)
Controls between rows and columns in a pane to control the size of the upper pane of a row or column.
Spliiter Box (split grid)
The button that dynamically splits the form at the top of the vertical scroll bar or the leftmost position of the horizontal scroll bar to create a new split pane.
Splitter Intersection)
Vertical or horizontal split control bar intersection, can be used for Synchronous Control of horizontal, vertical Pane size
4. Shared Scroll Bars)
Csplitterwnd supports the shared scroll bar. the scroll bar is a subform of csplitterwnd and is shared by different panes in the split form;
If WS_VSCROLL is defined when 1X2 CSplitterWnd is created, the vertical scroll bars shared by the two panes are created, for example:
[] [] [^]
[Pane00] [pane01] [|]
[] [] [V]
When the scroll bar is moved, the WM_VSCROLL message is sent to the two panes. The pane of the same column can share the horizontal scroll bar.
Note:
It is very useful to share a scroll bar in a split form. If two different views use a shared scroll bar, you must coordinate the scroll position and view display; the derived classes of all views can control the shared scroll bar through the ScrollBar Operation Method in CWnd, but some non-view derived classes, classes that do not use the ScrollBar control or implement methods through the standard Window, such as CEditView, are not suitable for sharing the scroll bar.
5 min size (Minimum size)
Each row in the split form has a minimum height limit, and each column has a minimum width limit. These two minimum values are used to control the minimum data size displayed in the pane;
The minimum size of the static split form is 0, 0, and the minimum size of the dynamic split form can be set at CSplitterWnd: creation;
These values can be changed through SetColumnInfo and SetRowInfo;
6. Unpublished API functions (protected interface)
The following sections discuss the technical details of unpublished CSplitterWnd so that advanced users can customize CSplitterWnd;
These APIs are not officially published and may be changed in future versions of MFC:
6.1 splitter bar (box) and tracker
Enum ESplitType {splitBox, splitBar, splitIntersection, splitBorder}; virtual void OnDrawSplitter (CDC * pDC, ESplitType nType, const CRect & rect); virtual void Merge (const CRect & rect ); these virtual functions can be used to implement split forms with different image representations.
6.2 create views and controls
Virtual BOOL CreateScrollBarCtrl (DWORD dwStyle, UINT nID); a scroll bar is created by default, but can be reloaded to create a new control at the scroll bar side.
6.3 Dynamic Splitting form
Virtual void DeleteView (int row, int col); virtual BOOL SplitRow (int cyBefore); virtual BOOL SplitColumn (int cxBefore); virtual void DeleteRow (int row ); virtual void DeleteColumn (int row); used to dynamically split the form logic (when the split form has a style SPLS_DYNAMIC_SPLIT)