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.

228 Day 7<br />

Figure 7.5.<br />

A form with<br />

AutoScroll <strong>in</strong><br />

action.<br />

Prevent<strong>in</strong>g Components from Be<strong>in</strong>g Moved<br />

or Sized<br />

Components can be locked <strong>in</strong>to place so that they cannot be moved. Lock<strong>in</strong>g components<br />

is useful if you know that a form’s design is f<strong>in</strong>al and you don’t want to worry about<br />

accidentally mov<strong>in</strong>g controls. To lock a form’s controls, choose Edit | Lock Controls from<br />

the ma<strong>in</strong> menu. Locked controls cannot be moved or sized. When controls are locked, their<br />

siz<strong>in</strong>g handles are gray with a black border. To unlock the controls aga<strong>in</strong>, choose Edit | Lock<br />

Controls aga<strong>in</strong>. The controls can now be moved as before.<br />

Order<strong>in</strong>g, Cutt<strong>in</strong>g, Copy<strong>in</strong>g, and Past<strong>in</strong>g<br />

Components<br />

You will place some components on top of one another <strong>in</strong> order to achieve a visual effect. For<br />

example, you can create a shadowed box by plac<strong>in</strong>g a white box over a black box (both would<br />

be Shape components). Obviously, you can’t have the shadow on top of the box, so you have<br />

to have some way of order<strong>in</strong>g the controls to tell <strong>C++</strong>Builder which controls go on top and<br />

which go on the bottom. Let’s do a simple exercise that illustrates this. Along the way you<br />

will also see how you can use Copy and Paste with components. First (as always), start with<br />

a blank form. Now do this:<br />

1. Click on the Additional tab on the Component Palette and choose the Shape<br />

component. Click on the form to place the shape. A white square appears on the<br />

form.<br />

2. Size the shape as desired (m<strong>in</strong>e ended up be<strong>in</strong>g 209 pixels by 129 pixels).<br />

3. Be sure the Shape component is selected. Choose Edit | Copy from the ma<strong>in</strong> menu.<br />

4. Choose Edit | Paste from the ma<strong>in</strong> menu. A copy of the shape is placed below and<br />

to the right of the orig<strong>in</strong>al shape. Conveniently, this is exactly where we want it.

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

Saved successfully!

Ooh no, something went wrong!