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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

VCL Components<br />

property set to true. However, when the user presses Enter on the<br />

keyboard, the first button <strong>in</strong> the tab order that has its Default property<br />

set to true will be <strong>in</strong>voked. Similarly, when the user presses the Esc key<br />

to close the form, the return value from ShowModal() will be the<br />

ModalResult value of the first button <strong>in</strong> the tab order that has its Cancel<br />

property set to true.<br />

The Enabled Property<br />

Earlier I discussed the Enabled property when I discussed components <strong>in</strong> general. This<br />

property is used a lot with buttons to enable or disable the button depend<strong>in</strong>g on the current<br />

state of the program or of a particular form. When a button is disabled (its Enabled property<br />

is set to false), its text is grayed out, and the button does not function. In the case of buttons<br />

with bitmaps on them (BitBtn and SpeedButton), the bitmap will also be grayed out<br />

automatically.<br />

Button components have only one method of <strong>in</strong>terest: the Click() method, which simulates<br />

a mouse click. When you call Click() for a button, the OnClick event of the button is executed<br />

just as if the user had clicked the button. As for events, typically only the OnClick event is used.<br />

Now let’s take a look at the different button components <strong>C++</strong>Builder provides.<br />

The Button Component<br />

The standard Button component is sort of like actor Danny DeVito—he a<strong>in</strong>’t pretty, but he<br />

sure gets a lot of work. There really isn’t anyth<strong>in</strong>g to add concern<strong>in</strong>g the standard Button<br />

component. It has a default Height property value of 25 pixels and a default Width property<br />

value of 75. Typically you will place a button on a form and respond to its OnClick event, and<br />

that’s about it.<br />

The BitBtn Component<br />

The BitBtn component is a perfect example of how a component can be extended to provide<br />

additional functionality. In this case the standard Button component is extended to allow a<br />

bitmap to be displayed on the face of the button.<br />

The BitBtn component has several properties over what the Button component provides. All<br />

these properties work together to manage the bitmap on the button and the layout between<br />

the bitmap and the button’s text. They are expla<strong>in</strong>ed <strong>in</strong> the follow<strong>in</strong>g sections.<br />

299<br />

8

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

Saved successfully!

Ooh no, something went wrong!