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.

Work<strong>in</strong>g with the Form Designer and the Menu Designer<br />

For the most part these menu items are self-explanatory, so I’m not go<strong>in</strong>g to go over each one<br />

right now. Rather, you will learn about each item on the speed menu via the hands-on<br />

approach. To beg<strong>in</strong>, let’s add a ma<strong>in</strong> menu to the ScratchPad application we created earlier.<br />

After that we’ll add a speed menu.<br />

Creat<strong>in</strong>g a Ma<strong>in</strong> Menu<br />

NOTE<br />

The Menu Designer allows you to quickly build any menu. The menu structure for a ma<strong>in</strong><br />

menu consists of a Ma<strong>in</strong>Menu component, which is represented by the VCL class TMa<strong>in</strong>Menu.<br />

Each item on the menu is a MenuItem component that is encapsulated <strong>in</strong> the TMenuItem class.<br />

You don’t need to be too concerned about the <strong>in</strong>tricacies of how these classes work together<br />

because the Menu Designer makes creat<strong>in</strong>g menus easy. With that brief overview, let’s add<br />

a ma<strong>in</strong> menu to the ScratchPad application.<br />

Add<strong>in</strong>g a Ma<strong>in</strong> Menu to the Form<br />

The first th<strong>in</strong>g you must do is add a Ma<strong>in</strong>Menu component to your form:<br />

By this time you have had some experience with <strong>C++</strong>Builder. From this<br />

po<strong>in</strong>t on I will abbreviate some of the steps that you need to take to<br />

perform certa<strong>in</strong> actions. For example, from here on I’ll say, “Place a<br />

Ma<strong>in</strong>Menu component on the form” rather than “Click on the Standard<br />

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

the form to place the component.” Don’t worry; I’ll still give plenty of<br />

detail when new operations are <strong>in</strong>troduced.<br />

1. Open the ScratchPad project created earlier <strong>in</strong> the chapter.<br />

2. Place a Ma<strong>in</strong>Menu component on the form and change its Name property to Ma<strong>in</strong>Menu.<br />

Notice that a Ma<strong>in</strong>Menu component has very few properties and no events. All the<br />

work of a menu is done by the MenuItem component.<br />

3. Double-click on the ma<strong>in</strong> menu icon. The Menu Designer is displayed.<br />

The Menu Designer looks like a blank form without grid po<strong>in</strong>ts. The Menu Designer can<br />

be sized <strong>in</strong> any way you want. The size is just for your convenience and has no bear<strong>in</strong>g on how<br />

the menu operates at runtime. At this po<strong>in</strong>t, the Menu Designer is wait<strong>in</strong>g for you to beg<strong>in</strong><br />

build<strong>in</strong>g the menu. Once you have created your first menu, you will f<strong>in</strong>d that menu creation<br />

is fairly easy and <strong>in</strong>tuitive.<br />

245<br />

7

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

Saved successfully!

Ooh no, something went wrong!