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.

NOTE<br />

Gett<strong>in</strong>g Your Feet Wet<br />

As you modify properties, <strong>C++</strong>Builder will immediately display the<br />

results of the property change when appropriate. As you type the new<br />

caption, notice that the w<strong>in</strong>dow caption of the form is chang<strong>in</strong>g to<br />

reflect the text you are typ<strong>in</strong>g.<br />

Now click the Run button on the speedbar (the one with the green arrow). (You could also<br />

press F9 or choose Run | Run from the ma<strong>in</strong> menu.) <strong>C++</strong>Builder beg<strong>in</strong>s to build the<br />

program. The compiler status dialog box, shown <strong>in</strong> Figure 1.2, is displayed, and you can<br />

watch as <strong>C++</strong>Builder whips through the files necessary to build your program. After a brief<br />

wait, the compiler status box disappears, the form is displayed, and the caption shows Hello<br />

World!. In this case, the runn<strong>in</strong>g program looks almost identical to the blank form. You may<br />

scarcely have noticed when the program was displayed because it is displayed <strong>in</strong> the exact<br />

location of the form <strong>in</strong> the Form Editor. (There is a difference, though, because the Form<br />

Editor displays an alignment grid and the runn<strong>in</strong>g program does not.) Congratulations—<br />

you’ve just written your first <strong>C++</strong> W<strong>in</strong>dows program with <strong>C++</strong>Builder. Wow, that was easy!<br />

“But what is it?” you ask. It’s not a lot, I agree, but it is a true W<strong>in</strong>dows program. It can be<br />

moved by dragg<strong>in</strong>g the title bar, it can be sized, it can be m<strong>in</strong>imized, it can be maximized,<br />

and it can be closed by click<strong>in</strong>g the Close button.<br />

Figure 1.2.<br />

The compiler status<br />

dialog box.<br />

Okay, so maybe display<strong>in</strong>g Hello World! just <strong>in</strong> the caption was cheat<strong>in</strong>g a little. Let’s spruce<br />

it up a bit. If you still have the Hello World program runn<strong>in</strong>g, close it by click<strong>in</strong>g the Close<br />

button <strong>in</strong> the upper-right corner of the w<strong>in</strong>dow. The Form Editor is displayed aga<strong>in</strong>, and you<br />

are ready to modify the form (and, as a result, the program).<br />

To make the program more viable, we’re go<strong>in</strong>g to add text to the center of the w<strong>in</strong>dow itself.<br />

To do this, we’ll add a text label to the form. First, click on the Standard tab of the<br />

Component Palette. The third component button on the palette has an A on it. If you put<br />

your mouse cursor over that button, the tool tip will display Label. Click the label button and<br />

then click anywhere on the form. A label component is placed on the form. Now turn your<br />

attention to the Object Inspector. It now displays the properties for Label1 (remember that<br />

before it was show<strong>in</strong>g the properties for Form1). Aga<strong>in</strong> the Caption property is highlighted.<br />

7<br />

1

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

Saved successfully!

Ooh no, something went wrong!