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.

274 Day 8<br />

Cont<strong>in</strong>u<strong>in</strong>g with this example, if you change the Name property of the edit control from<br />

MyEdit to FirstName, <strong>C++</strong>Builder will change the po<strong>in</strong>ter name to FirstName and the<br />

OnChange handler name to FirstNameChange(). It’s all done automatically; you don’t have to<br />

do anyth<strong>in</strong>g but change the Name property and trust that <strong>C++</strong>Builder will do its th<strong>in</strong>g.<br />

WARNING<br />

NOTE<br />

Never change the Name property at runtime. Never manually change a<br />

component’s name (the name that <strong>C++</strong>Builder assigned to the<br />

component’s po<strong>in</strong>ter) or event handler names <strong>in</strong> the Code Editor. If<br />

you do either of these, <strong>C++</strong>Builder loses track of components, and the<br />

results are not good, to say the least. You might even lose the ability to<br />

load your form. The only safe way to change the Name property of a<br />

component is through the Object Inspector.<br />

<strong>C++</strong>Builder assigns a default value to the Name property for all components placed on a form.<br />

If you place an Edit component, for example, <strong>C++</strong>Builder assigns Edit1 to the Name property.<br />

If you place a second Edit component on the form, <strong>C++</strong>Builder assigns Edit2 to that<br />

component’s Name property, and so on. You should give your components mean<strong>in</strong>gful names<br />

as soon as possible to avoid confusion and extra work later on.<br />

You can leave the default names for components that will never be<br />

referenced <strong>in</strong> code. For example, if you have several label components<br />

that conta<strong>in</strong> static (unchang<strong>in</strong>g) text, you can leave the default names<br />

because you won’t be access<strong>in</strong>g the components at runtime.<br />

HOUSE RULES: THE Name PROPERTY<br />

■ Change the Name property of a component from the default name to a mean<strong>in</strong>gful<br />

name as soon as possible.<br />

■ Components not referenced at runtime can be left with the <strong>C++</strong>Buildersupplied<br />

name.<br />

■ Never change the Name property of a component <strong>in</strong> code or at runtime.<br />

■ Make your components’ names mean<strong>in</strong>gful but not overly long.

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

Saved successfully!

Ooh no, something went wrong!