19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

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.

Here, the menu bar contains two menu items (Font <strong>and</strong> Size), referred to as top-level menu<br />

items. When the Font menu item is clicked, a dropdown list of two second-level menu items<br />

(Courier <strong>and</strong> TimesRm) appears. Although not visible here, the dropdown list under Size contains<br />

the two second-level menu items “12” <strong>and</strong> “24”. Each menu item is treated as a distinct<br />

control that responds to only one event—the click event. The click event is triggered not only<br />

by the click of the mouse button, but also for top-level items by pressing Alt+accessKey <strong>and</strong><br />

for second-level items by just pressing the access key. The click event for the Courier menu<br />

item in Figure 10-11 can be activated directly by pressing the shortcut key F1.<br />

FIGURE 10-11 A Simple Menu<br />

Menus are created with the Menu Editor window available from the Tools menu on the<br />

<strong>Visual</strong> <strong>Basic</strong> main menu bar. Figure 10-12 shows the Menu Design window used to create<br />

the menu in Figure 10-11. Each menu item has a Caption property (what the user sees) <strong>and</strong><br />

a Name property (used to refer to the item in the code.) For instance, the last menu item in<br />

Figure 10-12 has Caption property “24” <strong>and</strong> Name property “mnu24”. The following steps<br />

are used to create the Font-Size menu:<br />

FIGURE 10-12 The Menu Editor Window Used to Create the Menu in Figure 10-11<br />

1. Type &Font into the Caption box <strong>and</strong> type mnuFont into the Name box.<br />

2. Click on the Next button.<br />

3. Click on the Right Arrow button. (This creates the ellipses <strong>and</strong> indents the next<br />

menu item, which will be a second-level item.)<br />

4. Type &Courier into the Caption box <strong>and</strong> type mnuCourier into the Name box.<br />

5. Click on the arrow to the right of the Shortcut box <strong>and</strong> select F1 from the dropdown<br />

list.<br />

6. Click on the Next button.<br />

7. Type &TimesRm into the Caption box <strong>and</strong> type mnuTimesRm into the Name<br />

box.<br />

8. Click on the Next button:<br />

Five Additional Objects 309

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

Saved successfully!

Ooh no, something went wrong!