Sams Teach Yourself Visual Basic 6 in 24 Hours

Sams Teach Yourself Visual Basic 6 in 24 Hours

By Greg Perry

Menu Extras

You don't need to complete all the menu bar options. You already know how to add routine options. If you need to add additional menu elements, however, such as a submenu or a checked item, the mechanics of those additions are about as simple as the items that you added in the previous sections.

To practice adding a checked object, add one checked item to the View pull-down menu bar item. Add an indented option that uses Highlighted for the Caption item and mnuViewHighlighted for the Name. Click the Checked check box. The View | Highlighted option will initially be checked when the user displays the View pull-down menu. Your code can check and uncheck the item by changing the mnuViewHighlighted object's Checked property to True and False.

If you want to add a submenu from a pull-down menu item, add an additional level of indentation. For example, to add a two-option submenu off the File | Open option that gives the user an additional choice of Binary or Text (binary and text are two possible kinds of files), insert a place for the first item right beneath Open and click the right-arrow command button to add a second ellipsis. Type &Binary for the Caption property and mnuFileOpenBinary for the Name property. Insert an additional item beneath that, indented at the same level, and type &Text for the Caption property and mnuFileOpenText for the Name property.

Now that you've completed the menu (as far as we're taking it here), click OK. When the Menu Editor disappears, you'll see the application's Form window with the menu bar across the top of the screen. Open the File menu and then select Open to see the submenu like the one shown in Figure 17.8. Notice the right arrow next to Open, which indicates that an additional submenu will appear for that option.

17fig08.gif

Figure 17.8 The File menu is now complete.

Share ThisShare This

Informit Network