C ++ Builder first-study questions and answer (three)

zhaozj2021-02-16  61

3. Buttons Components

21) Q: In the WINDOWS program interface design, the button often uses, in C Builder, is the button be implemented by button components?

A: Yes, and C Builder's button components are very rich. BCB provides two types of buttons class components: one is the execution class button, and the other is the information class button. The so-called execution class refers to it usually used to start the program, such as buttons, bitmap buttons, acceleration buttons. The information button is generally used to get information, including radio buttons, and check boxes. Flexible use of various buttons, not only makes the program more colorful, but also improves the performance of the program.

22) Q: What are the commonly used properties and methods of button components?

A: For button components, the CAPTION property is used to describe the title of the button, that is, the text displayed on the button, which is very knowledge with the tag component, and we can also specify shortcuts for the button in this property.

When the Cancel property value is True, the user generates an OnClick event whenever you press the ESC key, and when there are multiple buttons on the form, the ESC key triggers the Taborder value to the Little ONCLICK event. Its default value is false

When the Default property value is TRUE, the user generates an OnClick event whenever the Enter is pressed, and the Cancel property is different. If the input focus is just on a button, then the button's ONCLICK event will be generated. Otherwise, the ONCLICK event of the button that is the smallest value of Taborder. Its default value is TRUE

The Hint property saves the button's prompt content, and when the user leaves the mouse cursor on the button, the prompt information will be displayed.

The showhint property is used to determine if the prompt text is displayed, the default value is false.

The constant event is an onclick event, an OnClick event is generated when a mouse click a button, and an OnClick event can be generated by shortcut keys, an Enter key, and an ESC key. In general, the button needs to increase the ONCLICK event handler.

23) Q: What is the characteristic of the bitmap button?

A: The bitmap button BitBTN can display the graphics in addition to the text like a normal button, in addition to the full properties with the general button, the bitmap button has a unique Kind property. This attribute is used to set the button which is in several predefined graphic buttons. This is several predefined buttons. These doing buttons are as follows:

Kind property value button appearance equivalent attribute setting BKCustom

The default value is used to develop BKOK to users

Caption = "ok" modalResult = MROK Default = true bkcancel

CAPTION = "Cancel" modalResult = mrcancel ca Zancel = true bkyes

CAPTION = "& yes" modalResult = mryes default = true bkno

CAPTION = "& no" modalResult = mRno ca Zan = true bkhelp

CAPTION = "& help" BKClose

Caption = "& close" BKABORT

CAPTION = "Abort" modalResult = mrabort bkretry

CAPTION = "& retry" modalResult = mrretry bkignore

CAPTION = "& ignore" modalResult = mrignore bkallcaption = "& all" modalResult = MRALL

When setting the property value of the KIND is set to BKCUSTOM, you can also assign other graphics to the bitmap button. The specific method is to select the glyph property in the object editor, and then click the omitial button in the Value column, it will appear. A graphic editing dialog requires the location of the positioning diagram.

Click the Load button to select a bitmap file in the file open dialog. It should be noted that if the bitmap selected is too large, the bitmap button will not automatically adjust its size, then you can only see some of the graphics.

24) Q: What is the role of NumglyPH attributes of bitmap button components?

A: The attribute NUMGLYPH indicates the number of bitmaps used by the bitmap button. When you need a bitmap button to use multiple bitmaps to indicate different states, bounce, etc., you must ensure that these bitmaps have the same size, and one Then, one level is arranged.

In C Builder, a bitmap button can have up to four bitmaps, so Numgraph is only 1 to 4, and C Builder determines which bitmap display according to the status of bitmap button.

In general, the first bitmap is displayed when the button is not selected.

When the button can't choose, the second bitmap is displayed.

When the button is clicked, the third bitmap is displayed.

When the user releases the mouse button, the first bitmap will be redisplayed.

When there is no hopeful bitmap, then the first bitmap is used.

25) Q: What are the important properties of the shortcut button?

A: The shortcut button is very similar to the bitmap button, or you can also display images, but there are some differences: shortcut buttons are generally smaller, default size 25 * 25, basically all display images without displaying text, maximum Differences, the shortcut can be kept in the state, while the other two types of buttons cannot be. The shortcut button is generally used to make toolbar buttons, then use it with Panel. Let's take a look at its important properties:

ALLOWALLUP: Set whether the shortcut button of a group can be all in the state of bounce. The default is false, which can be used to simulate the radio button to make the same group in the same group. If there is only one shortcut in a group, this property can be changed to TRUE. At this point, this button can switch between press and bounce two states, which can be used to simulate a check button.

Down: Indicates if the button is pressed, if set to TRUE, is in a pressed state.

GroupINDEX: The same shortcut button as a few properties is set to a group, ie the button of the same value is a group. The default is 0, indicating that this button does not group.

26) Q: What is the characteristic of the radio button?

A: The radio button RADIOBUTTON is a selection component of mutual exclusion, and only one radio button can only be selected at a set of radio buttons.

Although you can use only one radio button, it will lose its meaning as the radio button. The radio button is generally a group.

The radio button has only one relatively special attribute checked, which indicates whether the button is selected. By default, Checked properties are false, indicating that the button is not selected.

Also select the select button also has a CAPTION property, which means it can also be selected by shortcuts.

The radio button has some characteristics when used in group usage. When you place a radio button directly on the same container (such as form, panel, groupbox, etc.), that is, no matter 2 or dozens of radio buttons on the container They are all set, and only one of them can be selected each time. 27) Q: What should I do if I want to place more than a set of buttons on the form?

A: You can use two methods. One is to use the combobox, and the other is to use a radio button packet box (RadioGroup).

The combination frame given the names to combine many components to make the window neat and have an enormous, each set of different buttons use a combo box. When designing, first place the combo box on the form and then put the radio button on the packet box. It is necessary to remember that the placement will not be reversed. Once the radio button is placed in the group box, then this radio button belongs to this combo box, you can't remove it from the combo box, if you delete the combo box, all the radio buttons in the group box will also Be deleted at the same time.

In practical applications, we often use radio button to group boxes instead of radio buttons. Because the radio button packet box can contain multiple radio buttons, it is actually just a component. This is more intuitive and simple than using a packet box and multiple radio buttons.

28) Q: What special properties are there in the radio button packet box?

A: The radio button packet box has three properties that are relatively special:

Attributes Items is an object of class TStrings, which is very similar to the Lines property in the MEMO component, but their meaning is different, and the Lines property contains each row string displayed in the MEMO component, and the items attribute contains many strings. But each string represents a radio button in the radio button group.

Click the ITEMS Properties VALUE column to open a string editor, and then you can enter the title of the radio button in this editor. Each radio button takes up a row.

The columns attribute determines the number of columns in the radio button packet box. The default is 1, up to 16 columns, 16 columns.

The ItemIndex property is the serial number of the selected item in the radio group box. -1 means not pointing to any one.

29) Q: What is the role of check button (Checkbox)?

A: The check button is different from the radio button, you can select multiple check buttons at a time. The check button has several more important properties.

The Alignment property controls the location of the check box title.

TarightJustify title appears on the right taleftjustify title appears on the left side of the check box

The default is TATIHTJUSTIFY.

The allowgrayed property determines if the check box can be in a gray state. When the property value is True, the check box has three states, selected, unchecked, and gray; when the property value is false, the check box has only two states. The default is false.

Checked property determines if the check box is selected. The default is false.

To know the check box is selected, the unselected status is still grayed. When running, you can read the value of the running timber state using the program, the default value is cbunchecked.

Although the check box is not excluded, it is to say that each check button directly placed on the form is not interfered with each other, but it is best to use the check box packet. The benefits of doing this are for users to understand.

30) Q: How does Checkbox, how to complete dynamically change the title of its button? Can RadioGroup add? How to read the above three component titles? A: Checkbox, there is a CAPTION in the properties of Radiobutton, and its attribute value is the title of the button, so it should be easy to do with these two components:

CheckBox1-> CAPTION = "Information";

Label1-> CAPTION = CheckBox1-> CAPTION;

Radiobutton is the same as Checkbox, there is not much to say here.

There is an Items property in RadioGroup, which has said this problem in "chat BCB", so you have to add a button, you can use the following method:

RadioGroup1-> items-> add ("I am new");

Read can be accomplished using ItemsIndex:

Label1-> CAPTION = Radiogroup1-> items-> strings [radiogroup1-> itemindex];

String is converted to the selected sequence to the text you need, because Items is a TString object, which will often see in your later learning.

Be Note that there is also a CAPTION in RadioGroup, which is used to set the title to the radio grouping box, which is not related to the radio text.

(to be continued)

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

New Post(0)