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.

The <strong>C++</strong>Builder IDE Explored: Projects and Forms<br />

1. Switch back to the form by press<strong>in</strong>g F12. Choose W<strong>in</strong>dow | Tile from the form’s<br />

menu.<br />

2. You need to enter only a s<strong>in</strong>gle l<strong>in</strong>e of code for the event handler. The f<strong>in</strong>ished<br />

event handler will look like this:<br />

void __fastcall TMa<strong>in</strong>Form::Tile1Click(TObject *Sender)<br />

{<br />

Tile();<br />

}<br />

3. Switch back to the form and repeat the process for W<strong>in</strong>dow | Cascade. The<br />

f<strong>in</strong>ished function looks like this:<br />

void __fastcall TMa<strong>in</strong>Form::Cascade1Click(TObject *Sender)<br />

{<br />

Cascade();<br />

}<br />

4. Repeat the steps for the W<strong>in</strong>dow | Arrange All menu item. The s<strong>in</strong>gle l<strong>in</strong>e of code<br />

to add for the function body is<br />

ArrangeIcons();<br />

Okay, now we’re done with the ma<strong>in</strong> form. We can now move on to creat<strong>in</strong>g the MDI child<br />

form.<br />

Step 4: Create the MDI Child Form<br />

The MDI child form is surpris<strong>in</strong>gly simple. In fact, we don’t have to write any code at all:<br />

1. Create a new form us<strong>in</strong>g the New Form button on the toolbar or by choos<strong>in</strong>g<br />

File | New Form from the ma<strong>in</strong> menu.<br />

2. Change the Name property to Child. The Caption property can be ignored because<br />

we will be sett<strong>in</strong>g the dialog box’s caption at runtime.<br />

3. Change the FormStyle property to fsMDIChild. This is necessary for the form to be<br />

treated as an MDI child w<strong>in</strong>dow.<br />

That’s it for the form itself. Now let’s put an Image component on the form. The Image<br />

component will display the graphics file selected by the user.<br />

1. Click on the Additional tab on the Component Palette. Click the Image button<br />

and place an Image component anywhere on the form.<br />

2. Change the Name property to Image.<br />

209<br />

6

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

Saved successfully!

Ooh no, something went wrong!