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.

VCL Components<br />

Important Common Properties<br />

All components have certa<strong>in</strong> properties <strong>in</strong> common. For <strong>in</strong>stance, all visual components have<br />

Left and Top properties that determ<strong>in</strong>e where the component is placed on the form.<br />

Properties such as Left, Top, Height, and Width are self-explanatory, so I won’t go over them.<br />

A few of the common properties, however, warrant a closer look.<br />

The Align Property<br />

On Day 7, “Work<strong>in</strong>g with the Form Designer and the Menu Designer,” I discussed the Align<br />

and Alignment properties, so I won’t go over those aga<strong>in</strong> <strong>in</strong> detail. Refer to Day 7 for complete<br />

<strong>in</strong>formation on Align. It should be noted here, however, that not all components expose the<br />

Align property at design time. A s<strong>in</strong>gle-l<strong>in</strong>e edit control, for <strong>in</strong>stance, should occupy a<br />

standard height, so the features of the Align property do not make sense for that type of<br />

component. As you ga<strong>in</strong> experience with <strong>C++</strong>Builder, and depend<strong>in</strong>g on the type of<br />

applications you write, you will probably rely heavily on the Align property.<br />

Color My World<br />

NOTE<br />

The Color property sets the background color for the component. (The text color is set<br />

through the Font property.) Although the Color property is simple to use, there are a few<br />

aspects of component colors that should be po<strong>in</strong>ted out.<br />

The way the Color property is handled <strong>in</strong> the Object Inspector is somewhat unique. If you<br />

click on the Value column, you will see the drop-down arrow button <strong>in</strong>dicat<strong>in</strong>g that you can<br />

choose from a list of color values. That is certa<strong>in</strong>ly the case, but there’s more to it than that.<br />

If you double-click on the Value column, the Color dialog box is displayed. This dialog box<br />

allows you to choose a color from one of the predef<strong>in</strong>ed colors or to create your own colors<br />

by click<strong>in</strong>g the Def<strong>in</strong>e Custom Colors button. Figure 8.1 shows the Color dialog box after<br />

the Def<strong>in</strong>e Custom Colors button has been clicked.<br />

This is the same Color dialog box that will be displayed if you implement<br />

the ColorDialog component <strong>in</strong> your application.<br />

If you choose a color from the Color dialog box, you will see that the value of the Color<br />

property changes to a hexadecimal str<strong>in</strong>g. This str<strong>in</strong>g represents the red, green, and blue<br />

(RGB) values that make up the color. If you know the exact RGB value of a color (not likely!),<br />

you can type it <strong>in</strong>.<br />

275<br />

8

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

Saved successfully!

Ooh no, something went wrong!