12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

NOTE<br />

VCL Components<br />

form. Like the ListBox and ComboBox components discussed earlier, the RadioGroup component<br />

has an ItemIndex property that you can read at runtime to determ<strong>in</strong>e which item <strong>in</strong> the<br />

group is selected. Oh, by the way—the answer to the quiz is Redtailed Hawk (American<br />

Kestrel would also have been an acceptable answer, but it was not presented <strong>in</strong> the list).<br />

You can also use a GroupBox component to hold radio buttons. The<br />

GroupBox component is less convenient to use than the RadioGroup<br />

component, but it has more flexibility. You can place any type of<br />

control <strong>in</strong> a group box. Once placed <strong>in</strong> the group box, the controls and<br />

the group box itself can be moved as a unit at design time.<br />

The CheckBox component is used to allow users to turn an option on or off or to <strong>in</strong>dicate to<br />

a user that an option is currently on or off. A check box can have up to three states, depend<strong>in</strong>g<br />

on its style: on, off, or grayed. If the check box’s AllowGrayed property is false, it can only<br />

be checked or unchecked. When the AllowGrayed property is true, the check box can be any<br />

one of the three states. The grayed, or <strong>in</strong>determ<strong>in</strong>ate, state is handled programmatically. In<br />

other words, it’s up to you to decide what the grayed state means for your application. If the<br />

AllowGrayed property is false (the default), you can use the Checked property to determ<strong>in</strong>e<br />

whether the check box is checked or unchecked. If the AllowGrayed property is true, you must<br />

use the State property to determ<strong>in</strong>e (or set) the check box state. State will return either<br />

cbChecked, cbUnchecked, or cbGrayed.<br />

TIP<br />

To make a check box read-only but not grayed, place it on a panel and<br />

change the panel’s Enabled property to false.<br />

The Label Component<br />

The Label component is used to display text on a form. Sometimes the label text is<br />

determ<strong>in</strong>ed at design time and never changed. In other cases, the label is dynamic and is<br />

changed at runtime as the program dictates. Use the label’s Caption property to set the label<br />

text at runtime. The Label component has no specialized methods or events beyond what is<br />

available with other components. Table 8.8 lists the properties specific to the Label<br />

component.<br />

305<br />

8

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!