Win32 Controls: The Splitter |
|
Introduction to the Splitter Control |
Introduction |
A splitter is a bar that divides the body of a container into two sections. These sections are referred to as panes or frames:
|
The splitter bar is used to create independent sections holding various controls. The splitter can divide the sections horizontally or vertically, depending on how you create it. Among other things, the design and implementation allows displaying related data.
|
To support the splitter control, the VCL provides a class named TSplitter. The TSplitter class is derived from TGraphicControl:
To visually create a splitter bar, in the Additional section of the Tool Palette, click the TSplitter control and click the form.
Although you can add a splitter directly to a form or other container such as a frame, you should first add a panel. Set the panel Align property to one of the following values: alLeft, alTop, alRight or alBottom. Then add a splitter to the remaining section of the form (or frame). You can (should) then add another frame to finalize the sections of the splitting window. As a descendant of the TControl class, a splitter has such characteristics as a background color, the cursor, and a width:
As mentioned already, before creating a splitter, you should first add a panel and specify its alignment. The alignment you choose for that panel will serve as a pre-orientation for the splitter. In reality, the splitter is equipped with the Align property that it inherits from the TControl class. If you set the Align property of the panel to alLeft, alTop, alRight or alBottom, you should then add a splitter to the empty area of the form (or frame) and set the splitter's alignment to the same value:
After creating the splitter, in the remaining empty area of the form or frame, you should add another panel and set its alignment to alClient. In the same way, you can create as many sections as necessary and in any way.
|
To give a 3-D effect to a splitter, it has a Boolean property named Beveled: __property bool Beveled = {read=FBeveled,write=SetBeveled}; This allows the splitter to appear with a raised edge. If this property is set to True:
To use a splitter, the user holds the mouse on it and drag in the desired direction. This causes one section to narrow or shrink while the other section widens or grows. To let a user see the evolution of the dragging, the mouse is equipped with a cursor that may show a bar. To assist with this detail, the splitter has a property named ResizeStyle that is of type TResizeStyle: __property Extctrls::TResizeStyle ResizeStyle = {read=FResizeStyle,write=FResizeStyle}; The TResizeStyle enumeration is defined as follows: enum TResizeStyle{ rsNone, rsLine, rsUpdate, rsPattern }; To visually specify the resizing style, access the Object Inspector for the splitter and select the desired value from the ResizeStyle field:
As reviewed already, to use a splitter, the user can click and drag it to the desired direction. By default, the user can drag the splitter up to the extreme border of the container. This may get the splitter to reach the border and hide itself. If the user doesn't know how to restore the splitter, it would appear that the application doesn't have a splitter anymore. To solve this problem, you can set a minimum size for each of the sections that the splitter divides. To let you specify a minimum size, you can use the MinSize property of the TSplitter class: __property int MinSize = {read=FMinSize,write=FMinSize}; The default value of the TSplitter::MinSize property is 30. You can change it to a value of your choice. |
|
|||||||||
|
|
||
Home | Copyright © 2010-2016, FunctionX | |
|