C ++ Builder first-study and answer (11)

zhaozj2021-02-16  39

11. Toolbar Components

87) Q: The toolbar is often used by Windows programming. Can C Builder can implement this function?

A: Of course, the tool strip is composed of a plurality of graphic buttons, which are separated into many groups by separators, each of which can accomplish specific work. The button on the toolbar has a characteristic similar to the bitmap button - can have multiple bitmaps, which will display different bitmaps when the button is in different states, such as pressing, fail, etc. The method of previous C Builder production toolbar is to be implemented by putting the acceleration button on the panel assembly panel. Now, we don't have to use the combination of these two components, as long as you use Toolbar to create a toolbar. The toolbar is more difficult to master, which is not easy to master because it contains three attributes with the TtoolButton components: Grouped, AllowAllup, and Down, their combination can produce a variety of different effects button groups. These three attributes we must understand it.

88) Q: Please tell me how to use the tool of TOOLBAR?

A: Ok, let's start with Toolbar attributes, understand it by analyzing some important properties. Toolbar contains some properties that have not been seen in front:

The ButtonHeight property indicates the height of the button in the toolbar.

The ButtonWidTh property is used to set the width of the button in the toolbar.

When the FLAT property is TRUE, the toolbar is transparent, and the boundary between the toolbar is disappeared. Commonly known as flat tool bars, its default value is false.

Indent is used to create a edge area on the left side of the toolbar.

Showcaptins determines if the title is allowed to display the title on the tool bar. The default is false.

WRAPABLE Set whether the button on the toolbar is allowed to wrap. The default is TRUE.

List attribute, when this property is True, the icon of the toolbar is on the left and the title is right. At the icon of the button on the headline, the icon of the button is under. The default is false.

Images is used to set the list of icons that appear on the button normally.

HotImages is used to set the icon list that is displayed on the button.

DisabledImages is used to set the icon list when the button is failed.

All button displayed on the toolbar is included in these three icons lists.

In the list of listView components described earlier, attribute LargeImages and SmallImages represent a list of icons displayed in two different states. These three attributes of Toolbar have similar features, which represent a list of icons that are displayed when the mouse pointing to the toolbar and the button fails.

In addition, there are several runtime attributes:

The ButtonCount property indicates the number of buttons in the toolbar.

Buttons stores a list of buttons in the toolbar.

RowCount indicates the number of rows of the toolbar.

89) Q: Why do C Builders use the icon list to manage the icons on the toolbar?

A: Because this can centrally manage a large number of icons, it greatly reduces the burden of programmers.

A: To set up a toolbar for the application, you can follow the steps below:

(1) Select the toolbar component from the tab WIN32 and place it on the form.

Note that the toolbar assembly just placed on the form must be at the top of the form, because the align attribute of the toolbar is set to Altop.

(2) Add two imagelist components on the form and introduce icons for these components.

(3) Give an ImageList component to the property of the toolbar, another dendimages that give the toolbar. (4) Right-click the toolbar and select New Button in the pop-up menu.

At this time, a button will appear on the toolbar, this button has no title. This is because the SHOWCAPTION attribute of the toolbar is set to false. In fact, this button has a default title Toolbutton1.

This newly created button is different from the buttons of our previous introduction, it is a TTTOOLBUTTON component.

(5) Select the button on the toolbar and change the button's imageIndex property to the index number of the desired icon. This icon is actually stored in the ImageList component.

(6) Repeat the fourth steps and fifth steps and create more buttons on the toolbar. Such a toolbar is established.

90) Q: The button on the toolbar seems to be different from ordinary buttons. What is the characteristic it?

A: The button on the toolbar is a TtoolButton component. It includes some features related to the toolbar that simplifies the configuration of the toolbar and add some display characteristics. TtoolButton has some important properties.

The AllowAllup property allows the buttons in a group all in unchecked states. The default is False.

Down property specifies whether the button is selected. When the design is set to True during the design, the button is initialized to the selected state, the default value is false.

The DropDownMenu property connects a pop-up menu to the button.

The ImageIndex property specifies the index number of the icon appearing on the button.

The Indeterminate property determines if the button is in an intermediate state that is neither selected. The default is false.

The WRAP property is forced this button to be the last button of this line, and the next button starts from the next line. The default is false.

The Style property is used to determine the style of the button, which can have five different values, which represent five different styles of buttons, respectively.

The TBSButton represents the button normally displays the same as the general acceleration button.

TBSCHECK indicates that the Down property can be switched when you click this type of button. Once you have selected the button, the button will keep the selected state until click again.

The TBSDropDown indicates that the button is displayed as a downward arrow.

The TBSseParator indicates that the button displays a space on the toolbar.

The TBSDIVIDER indicates that the button is displayed as a vertical line segment on the toolbar.

The GroupD property determines if the buttons of the plurality of TBSCHECK types are allowed to make a group. The default is False. If the continuous multiple buttons, each button's Groupeed property is set to true, and the style property is set to TBSCHECK, then these components can only select one at a time. Select one of the buttons will make the other buttons becomes unselected.

91) Q: How to create a tool bar with an acceleration button?

A: Another way of creation of the toolbar is to use the panel component accelerator button SpeedButton method. The acceleration button has been mentioned earlier, it is similar to the bitmap button, and it also places the text and icons using attributes Caption and Glyph, but the acceleration button has some attributes to be special.

Let's first introduce the properties of the acceleration button:

GroupIndex: You can use the GROUPINDEX property to make the acceleration button like a radio button. That is, the GroupIndex attribute of multiple radio buttons gives the same value to make a set, so that the button in this group can only have a button at a time, when you press a button, other buttons will Will bounce. It should be noted that GroupIndex must be greater than 0. If the GroupIndex property is equal to 0, then the button is a normal acceleration button.

Down: The property value can control if the button is in a statement. When the value value is TRUE, the button is in the prescript. You can set the property down to True when designing, so when the program is running, the button is in the down state. ALLOWALLUP: This property is used to specify whether all acceleration buttons in a group can be at the same time. When this property is TRUE, click the button pressed in the group, this button will bounce. When this property is false, click the button pressed in the group, this button does not bounce.

If you compare the accelerator button and the TToolButton component, they all have the three properties described above, but the TToolButton component is used to use the properties Group to complete the function similar to GroupIdex.

92) Q: What is the difference between using the acceleration button design tool strip and what is different compared with the TOOLBAR assembly?

A: You must first place panel assemblies on the form with acceleration button design toolbar, and it should be set to Altop (because the toolbar is typically placed at the top of the window). Then place the acceleration button on the panel assembly.

Generally, the Caption and Glyph properties of the button are usually used to set the text and icons for the acceleration button. If these buttons are just like a normal button, then this is set. But if these buttons are used like a radio button, the GroupIndex property must be set.

93) Q: How do you use acceleration buttons to design a tool bar?

A: We want to use the controllable component of the Additional page Controlbar, SpeedButton and the WIN32 page Toolbar. Let's take a look at his implementation:

1 Double-click ControlBar and put her in the form;

2 Double-click Toolbar and put it on Controlbar;

3 Add SpeedButton on Toolbar;

4 Select a spetedButton, find the glyph property in the Object Inspector to select a picture.

* SpeedButton's FLAT is changed to TRUE, then the button is transparent.

* AutoSize is changed to TRUE, the size of the container varies with the capacity

12. Status section components

94) Q: In Windows programming, the status bar can display some current status information of the program, which is a very useful component, which is also widely used in many programs, how does C Builder write status strips?

A: Status StatusBar is actually consisting of a set of state panels, usually displayed at the bottom of the application window, and its function is mainly to display some prompt information and status information. For example, a state strip is displayed at the bottom of C Builder's code editor, and a plurality of state panels are displayed.

The status bar can only display a state panel or a plurality of state panels can also be displayed. When multiple status panels are displayed, the status bar is split into several parts, each of which has its own text property, and the information can be displayed in the status bar through this property.

If you want to display multiple status panels on the status bar, you need to set the SIMPLEPANEL property of the status bar to false, otherwise only one state panel can be displayed.

If the status strip only needs to display a status panel, it is possible to place the status bar simply on the form. The text on the form is saved in the properties SimpleText. If you want to display multiple status panels, you need to create multiple status panels using the panel editor. Click the omitial button (or double-click the menu bar) in the Value column of the properties panels, you can open the Status panel editor.

Click the button Add on the editor to increase the status panel on the status bar. Click the newly created status panel in the panel editor, which will list the properties of the status panel in the Object Editor. 95) Q: You can see that there are five attributes on the status panel on the status bar. What role is they?

A: The alignment property is used to determine the alignment of the text displayed in the panel. Its possible value is: taleftjustify indicates that the left alignment, TARIGHTJUSTIFY indicates that the right alignment and Tacenter represent the center alignment. The default is TALEFTJUSTIFY.

Bevel is used to determine the style of the panel. There are three ways, NONE indicates that the panel is in a flat state; the Lowered represents the panel sink; raised represents the protrusions.

The STYLE property is used to determine what is displayed in the panel is a text text or OwnerDraw self-drawing graphics. If you want to make a picture in the panel, then you need to write the OONPAnel event processing.

The Text property is used to save the string displayed in the panel.

Width is used to set the length width of the panel.

转载请注明原文地址:https://www.9cbs.com/read-26007.html

New Post(0)