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.

296 Day 8<br />

NOTE<br />

As with the edit components we looked at earlier, there are very few ListBox and ComboBox<br />

methods. The Clear() method will clear the control of all data. The ItemAtPos() methods<br />

will return the list box item at the specified x and y coord<strong>in</strong>ates. The SelectAll() method<br />

will select the text <strong>in</strong> the edit control portion of a combo box.<br />

Easily the most-used event when deal<strong>in</strong>g with combo boxes and list boxes is the OnClick<br />

event. Use this event to determ<strong>in</strong>e when a selection has been made <strong>in</strong> the list box.<br />

Click<strong>in</strong>g on the edit portion of a combo box or the drop-down button<br />

does not result <strong>in</strong> an OnClick event be<strong>in</strong>g sent. Only when the list box<br />

portion of a combo box is clicked will the OnClick event occur.<br />

The OnChange event can be used to detect changes to the edit portion of a combo box just as<br />

it is used with edit controls. The OnDropDown event is used to detect when the drop-down<br />

button on a combo box has been clicked. The OnMeasureItem and OnDrawItem events are used<br />

with owner-drawn list boxes and owner-drawn combo boxes.<br />

Button, Button, Who’s Got the Button?<br />

NOTE<br />

VCL conta<strong>in</strong>s several types of buttons that you can use <strong>in</strong> your applications. Although not<br />

all of them could be considered to be based on the standard W<strong>in</strong>dows button control, I will<br />

still address all the button types here. Before we look at the specific button components,<br />

though, let’s cover some of the basics.<br />

When sett<strong>in</strong>g the Caption property of a button, use the ampersand (&)<br />

just as you would when sett<strong>in</strong>g the Caption property of menu items.<br />

The character after the ampersand will be underl<strong>in</strong>ed and will be the<br />

accelerator for the button.<br />

Button Basics<br />

The button components only have about three properties of note.<br />

The ModalResult Property<br />

The ModalResult property is used to provide built-<strong>in</strong> form clos<strong>in</strong>g for forms displayed with<br />

ShowModal(). By default, ModalResult is set to mrNone (which is #def<strong>in</strong>ed as 0). Use this value

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

Saved successfully!

Ooh no, something went wrong!