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.

338 Day 9<br />

WARNING<br />

NOTE<br />

Plac<strong>in</strong>g any code between the published keyword and the private<br />

keyword can cause problems with your program. In some cases, you<br />

might just get compiler or l<strong>in</strong>ker errors. In other cases, your program<br />

might be beyond repair (unusual but possible). Get <strong>in</strong> the habit of<br />

avoid<strong>in</strong>g the published section like the plague.<br />

If you’re an astute student, you may be scratch<strong>in</strong>g your head right now.<br />

In the first four chapters we covered the basics of the <strong>C++</strong> language.<br />

You learned about private, protected, and public class access, but not<br />

a word about the published keyword. The reason is simple: published<br />

is not a <strong>C++</strong> keyword. The published keyword is a <strong>Borland</strong> extension<br />

to <strong>C++</strong> and doesn’t exist <strong>in</strong> ANSI standard <strong>C++</strong>. This keyword was<br />

added to allow the <strong>C++</strong> language to take advantage of the power of<br />

components.<br />

Notice that l<strong>in</strong>es 59 and 60 <strong>in</strong> List<strong>in</strong>g 9.1 have comments that say User declarations. You<br />

can safely place any of your own class data members or class member function declarations<br />

<strong>in</strong> either the private or the public section of the class declaration.<br />

A Word About Status Bars and H<strong>in</strong>ts<br />

In a moment we’re go<strong>in</strong>g to add support for h<strong>in</strong>t text displayed <strong>in</strong> the status bar of the<br />

ScratchPad program. Before we do, though, you need a brief primer on how h<strong>in</strong>t text is<br />

handled.<br />

When the Application object’s ShowH<strong>in</strong>t property is set to true (the default), and the mouse<br />

cursor is placed over a component that also has its ShowH<strong>in</strong>t property set to true, a h<strong>in</strong>t event<br />

is triggered. The Application object has an event called OnH<strong>in</strong>t that occurs whenever a h<strong>in</strong>t<br />

event is triggered. The Application’s H<strong>in</strong>t property will conta<strong>in</strong> the h<strong>in</strong>t text for the control<br />

that generated the h<strong>in</strong>t event. An application can use the OnH<strong>in</strong>t event to display the h<strong>in</strong>t on<br />

a status bar.<br />

The problem is that you can’t directly access the OnH<strong>in</strong>t event of the Application object.<br />

What you can do, however, is reassign the value of OnH<strong>in</strong>t to po<strong>in</strong>t to one of your own<br />

functions. Then, when the h<strong>in</strong>t event occurs, the event gets rerouted to your own OnH<strong>in</strong>t<br />

handler. To do that, you have to write your own event handler for the OnH<strong>in</strong>t event. Let’s do<br />

that next.

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

Saved successfully!

Ooh no, something went wrong!