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.

Figure 5.1.<br />

The Object Inspector<br />

w<strong>in</strong>dow.<br />

NEW TERM<br />

NOTE<br />

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

Properties are often tied to access methods that execute when the property is modified.<br />

Th<strong>in</strong>gs start to get a little confus<strong>in</strong>g at this po<strong>in</strong>t. As I said, VCL is<br />

written <strong>in</strong> Pascal. Pascal uses the term method where <strong>C++</strong> uses the term<br />

function. To further muddy the waters, Pascal uses the term function to<br />

refer to a method that returns a value, and the term procedure to refer to<br />

a method that does not return a value. I would be happy enough to call<br />

them all functions (be<strong>in</strong>g the old <strong>C++</strong> hacker that I am), but when<br />

discuss<strong>in</strong>g VCL I will use the Pascal parlance. For the most part I will<br />

use the generic term method.<br />

Properties can be changed at design time (when you are design<strong>in</strong>g your form) and at runtime<br />

(when the program is runn<strong>in</strong>g through code you write). In either case, if the property has an<br />

access method, that access method will be called and executed when the property is modified.<br />

You have already seen an example of chang<strong>in</strong>g a property at design time when you changed<br />

the Left property and watched the form move on the screen. That is one of the strengths of<br />

VCL and how it is used <strong>in</strong> <strong>C++</strong>Builder: You can <strong>in</strong>stantly see on the screen what the result<br />

of your design change will be. Not all properties are able to show a visible change on the form<br />

at design time, however, so this does not happen <strong>in</strong> every case. Still, when possible the results<br />

of the new property value are immediately shown on the form.<br />

To change a property at runtime, you simply make an assignment to the property. When you<br />

make an assignment, VCL works beh<strong>in</strong>d the scenes to call the access method for that<br />

property. To change the Left property at runtime, you would use code like this:<br />

Ma<strong>in</strong>Form->Left = 200;<br />

<strong>14</strong>1<br />

5

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

Saved successfully!

Ooh no, something went wrong!