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.

NOTE<br />

<strong>C++</strong> Class Frameworks and the Visual Component Model<br />

Some properties use an array as the underly<strong>in</strong>g data member. To illustrate let’s put a memo<br />

component on our blank form. Go to the <strong>C++</strong>Builder Component Palette, choose the<br />

Standard tab, and click on the Memo button. (The tool tip will tell when you are over the<br />

Memo button.) Now move to the form and click on the form where you want the top-left<br />

corner of the memo to appear. As soon as you place the memo component on the form, the<br />

Object Inspector switches to show you the properties of the component just placed on the<br />

form, <strong>in</strong> this case a TMemo. Locate the L<strong>in</strong>es property and click on it. Notice that the property<br />

value conta<strong>in</strong>s the text (TStr<strong>in</strong>gs) and that there is a little button with an ellipsis (…) to the<br />

right of the property value.<br />

The ellipsis button tells you that this property can be edited by <strong>in</strong>vok<strong>in</strong>g<br />

a property editor dialog box. For an array of str<strong>in</strong>gs, for <strong>in</strong>stance, a<br />

dialog box will be displayed <strong>in</strong> which you can type the str<strong>in</strong>gs. In the<br />

case of the Font property, click<strong>in</strong>g the ellipsis button will <strong>in</strong>voke the<br />

Choose Font dialog box. The exact type of the property editor is<br />

property specific, although certa<strong>in</strong> properties can share a common<br />

editor. You can br<strong>in</strong>g up the property editor by click<strong>in</strong>g the ellipsis<br />

button or by double-click<strong>in</strong>g the property value.<br />

The L<strong>in</strong>es property for a memo component is an array of str<strong>in</strong>gs. When you double-click the<br />

Value column, the str<strong>in</strong>g editor is displayed and you can then type the str<strong>in</strong>gs you want to<br />

be displayed <strong>in</strong> the memo component when the application runs. If you don’t want any<br />

str<strong>in</strong>gs displayed <strong>in</strong> the memo component, you will need to clear the property editor of any<br />

str<strong>in</strong>gs.<br />

Properties can be <strong>in</strong>stances of other VCL classes. The Font property is an obvious example.<br />

A font <strong>in</strong>cludes th<strong>in</strong>gs like the typeface, the color, the font size, and so on. Locate the Font<br />

property <strong>in</strong> the Object Inspector. (It doesn’t matter whether you have the memo component<br />

or the form selected.) Notice that there is a plus sign before the word “Font.” This tells you<br />

that there are <strong>in</strong>dividual properties with<strong>in</strong> this property that can be set. If you double-click<br />

on the property name, you will see that the Object Inspector expands the property to reveal<br />

the <strong>in</strong>dividual elements of that property. You can now edit the elements of the Font property<br />

<strong>in</strong>dividually. The same sett<strong>in</strong>gs can be edited by <strong>in</strong>vok<strong>in</strong>g the Property Editor. Either method<br />

can be used, and <strong>in</strong> the end the results are the same.<br />

NEW TERM<br />

Some properties are sets, or collections of other properties.<br />

The Style property with<strong>in</strong> the Font object is a good example of a set. Notice that Style has<br />

a plus sign <strong>in</strong> front of it. If you double-click on the Style property, you will see that the Style<br />

<strong>14</strong>3<br />

5

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

Saved successfully!

Ooh no, something went wrong!