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.

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

Summary<br />

Today you have had a look <strong>in</strong>to some of the basic components that <strong>C++</strong>Builder provides. You<br />

have learned about components <strong>in</strong> general, and you have learned about some of the specifics<br />

of the components that are based on W<strong>in</strong>dows controls. It is important to understand the<br />

basic controls available <strong>in</strong> W<strong>in</strong>dows and the <strong>C++</strong>Builder components that represent those<br />

controls. Today ends with an exam<strong>in</strong>ation of the W<strong>in</strong>dows common dialog boxes.<br />

Workshop<br />

The Workshop conta<strong>in</strong>s quiz questions to help you solidify your understand<strong>in</strong>g of the<br />

material covered and exercises to provide you with experience <strong>in</strong> us<strong>in</strong>g what you have learned.<br />

You can f<strong>in</strong>d answers to the quiz questions <strong>in</strong> Appendix A, “Answers to Quiz Questions.”<br />

Q&A<br />

Q If I change the Name property of a component us<strong>in</strong>g the Object Inspector,<br />

<strong>C++</strong>Builder will automatically change all references to that component <strong>in</strong> my<br />

code, right?<br />

A Yes and no. <strong>C++</strong>Builder will change all references to that component name <strong>in</strong><br />

<strong>C++</strong>Builder-generated code, but it will not change any user-written code.<br />

Q The OpenDialog component is obviously a visible component. Why is it called a<br />

nonvisual component?<br />

A Because it is not visible at design time. It is visible only at runtime when you<br />

<strong>in</strong>voke it with the Execute() method.<br />

Q Why is it important to change the Name property only with the Object Inspector?<br />

A As you work with the Form Designer, <strong>C++</strong>Builder writes code based on the Name<br />

property. If you later change the Name property either by directly edit<strong>in</strong>g the source<br />

files or at runtime, all references to that form or component will be <strong>in</strong>correct and<br />

will likely lead to your program refus<strong>in</strong>g to compile or crash<strong>in</strong>g at runtime.<br />

Q I seem to be us<strong>in</strong>g properties more than methods when deal<strong>in</strong>g with my<br />

components <strong>in</strong> code. Is that wrong?<br />

A Not at all. In fact, that’s the way VCL components are designed. A well-written<br />

component makes maximum use of properties. For this reason you may not use a<br />

component’s methods very often. Use methods when necessary, but otherwise use<br />

properties to manipulate your components at runtime.

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

Saved successfully!

Ooh no, something went wrong!