MFC split form (Splitter Windows)

Source: Internet
Author: User

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 you control the split or stop split of a view, the additional pane is created or destroyed; this kind of dynamic split starts with a separate view. splitter box is used to initialize the split. When a view can be split in two directions, three new views are created and displayed as three new panes. When split is active, split box) the splitter bar will be drawn between the panes just like a split control bar. When a user removes the split, the additional pane will be 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 both separated forms in this style.

when you create a split form of any style, you must specify the maximum number of rows and columns of the split form.
A split form of the static style, each pane must be created with 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 MFC ColumnsProgramBoth directly or indirectly use the split form. Dynamic split form is used in section 4th of the 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 partition space of the pane, shares the vertical scrollbar with the row, and shares the horizontal scrollbar with the column )); at the same time, the subscript of the row and column starts from 0, 0, that is, the first window is the pane of 0th columns of 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 shared scroll bars, the scroll bar is a subform of csplitterwnd and is shared by different panes in the split form.

If ws_vscroll split is declared when 1X2 csplitterwnd is created, the vertical scroll bars shared by the two panes are created as follows:
[] [] [^]
[pane00] [pane01] [|]
[] [] [v]
when moving the scroll bar, the wm_vscroll message is sent to 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 the 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 in cwnd, however, some non-View-Derived classes that do not use the scrollbar control or use standard Windows implementation methods, such as ceditview, are not suitable for sharing the scroll bar.

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 with 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 oninverttracker (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 spls_dynamic_split style)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.