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.

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

4. Create the MDI child forms.<br />

5. Create an About box.<br />

6. Stand back and admire our work.<br />

There’s no po<strong>in</strong>t <strong>in</strong> dawdl<strong>in</strong>g (time is money!), so let’s get right to it.<br />

Step 1: Create the Ma<strong>in</strong> W<strong>in</strong>dow Form<br />

First we’ll create the ma<strong>in</strong> w<strong>in</strong>dow form. The ma<strong>in</strong> w<strong>in</strong>dow for an MDI application must<br />

have the FormStyle property set to fsMDIForm. We will also need to add a menu to the<br />

application, as well as File Open and File Save dialog boxes:<br />

1. Start <strong>C++</strong>Builder and choose File | New Application from the ma<strong>in</strong> menu.<br />

2. For the ma<strong>in</strong> form, change the Name property to Ma<strong>in</strong>Form.<br />

3. Change the Caption property to Picture Viewer.<br />

4. Change the Height to 450 and the Width to 575.<br />

5. Change the FormStyle to fsMDIForm.<br />

Okay, now we’ve got the ma<strong>in</strong> part of the form done. Next we’ll add a menu to the form.<br />

Because I haven’t discussed the Menu Editor yet, we’ll take the easy route to creat<strong>in</strong>g a menu.<br />

To do that, we’ll take advantage of a <strong>C++</strong>Builder feature that allows us to import a predef<strong>in</strong>ed<br />

menu:<br />

1. Click on the Standard tab of the Component Palette and click the Ma<strong>in</strong>Menu<br />

button.<br />

2. Drop a Ma<strong>in</strong>Menu component on the form. It doesn’t matter where you drop it<br />

because the icon represent<strong>in</strong>g the menu is just a placeholder and won’t show on the<br />

form at runtime.<br />

3. Change the Name property to Ma<strong>in</strong>Menu.<br />

4. Double-click on the Ma<strong>in</strong>Menu component. The Menu Editor is displayed. (We’ll<br />

look at the Menu Editor <strong>in</strong> more detail tomorrow.)<br />

5. Place your cursor over the Menu Editor and click your right mouse button. The<br />

Insert Template dialog box appears. Choose Insert from template… from the speed<br />

menu. Figure 6.15 shows the Insert Template dialog box with the Menu Editor<br />

beh<strong>in</strong>d it.<br />

6. Choose MDI Frame Menu and click OK. The menu is displayed <strong>in</strong> the Menu<br />

Editor.<br />

7. Click the system close box on the Menu Editor to close it.<br />

205<br />

6

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

Saved successfully!

Ooh no, something went wrong!