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.

<strong>14</strong>8 Day 5<br />

TIP<br />

You can center components visually, but for a more exact method you<br />

can use the Alignment Palette. Choose View | Alignment Palette from<br />

the ma<strong>in</strong> menu and then click the Center horizontally <strong>in</strong> w<strong>in</strong>dow<br />

button on the Alignment Palette to center a component horizontally on<br />

the form.<br />

We will use this button to alternately show and hide the memo component. Now we need<br />

to write some code so that the button does someth<strong>in</strong>g when clicked. Be sure the button<br />

component is selected and then click on the Events tab <strong>in</strong> the Object Inspector. A list of the<br />

events that a button component is designed to handle is presented. The top event should be<br />

the OnClick event. Double-click on the value column of the OnClick event. What happens<br />

next is one of the great th<strong>in</strong>gs about visual programm<strong>in</strong>g. The Code Editor comes to the top<br />

and displays the OnClick function, ready for you to type code. Figure 5.3 shows the Code<br />

Editor with the OnClick handler displayed.<br />

Figure 5.3.<br />

The <strong>C++</strong>Builder<br />

Code Editor with the<br />

OnClick handler<br />

displayed.<br />

NOTE<br />

This function looks like the class member functions I discussed on Day<br />

3 and, <strong>in</strong> fact, that’s exactly what it is. The only difference is that<br />

<strong>C++</strong>Builder functions use the __fastcall keyword (note that two

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

Saved successfully!

Ooh no, something went wrong!