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 />

The Font dialog box has a s<strong>in</strong>gle event, OnApply, that will occur when the user clicks the Apply<br />

button on the F<strong>in</strong>d dialog box. The Apply button will not be present on the Font dialog box<br />

unless you have first created a valid (not empty) event handler for the OnApply event.<br />

The F<strong>in</strong>d and Replace Dialog Boxes<br />

The F<strong>in</strong>d and Replace dialog boxes provide users the capability to enter text to search for and<br />

text to replace the found text with, and a variety of search and replace options. The F<strong>in</strong>d dialog<br />

box is encapsulated <strong>in</strong> the VCL component F<strong>in</strong>dDialog, and the Replace dialog box is<br />

represented by the ReplaceDialog component. The Replace dialog box, which conta<strong>in</strong>s<br />

everyth<strong>in</strong>g found on the F<strong>in</strong>d dialog box, plus the extra replace features, is shown <strong>in</strong> Figure<br />

8.11.<br />

Figure 8.11.<br />

The Replace dialog box.<br />

Major properties of the F<strong>in</strong>dDialog and ReplaceDialog components <strong>in</strong>clude F<strong>in</strong>dText (the<br />

text to f<strong>in</strong>d), ReplaceText (the text with which to replace the found text), and Options.<br />

Obviously, the F<strong>in</strong>dDialog does not have a ReplaceText property. The Options property<br />

conta<strong>in</strong>s a wide variety of <strong>in</strong>formation about the various options that the user had set at the<br />

time the F<strong>in</strong>d Next, Replace, or Replace All button was clicked.<br />

The Execute() method for the F<strong>in</strong>dDialog and ReplaceDialog components is a little different<br />

than it is with the other common Dialog components. First, the F<strong>in</strong>d and Replace dialog<br />

boxes are modeless dialog boxes. As soon as the dialog is displayed, the Execute() method<br />

returns. Because the dialog is modeless, the return value from Execute() is mean<strong>in</strong>gless (it’s<br />

always true). Instead, the F<strong>in</strong>d and Replace dialog boxes use the OnF<strong>in</strong>d and OnReplace events<br />

along with the Options property to determ<strong>in</strong>e what is happen<strong>in</strong>g with the dialog box. The<br />

OnF<strong>in</strong>d event occurs when the F<strong>in</strong>d Next button is clicked. The ReplaceDialog has an OnF<strong>in</strong>d<br />

event, but it also has an OnReplace event that is fired when the Replace or Replace All button<br />

is clicked. Use these events to determ<strong>in</strong>e when the user has requested a f<strong>in</strong>d or replace action.<br />

Your programs should read the Options property to determ<strong>in</strong>e how the user <strong>in</strong>tended the f<strong>in</strong>d<br />

or replace operation to be carried out.<br />

313<br />

8

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

Saved successfully!

Ooh no, something went wrong!