|
|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
What Item Goes In What Menu?The Testing Department gives you a call to ask why the Paste item in your new application is in the View menu. You ask if they had a different menu in mind, and they mention something about the Edit menu. How can you avoid such calls? With the following lists. Users expect to find certain standard items in certain menus if your program is going to support those items. To start us off, heres the kind of item you might find in the File menu (note that not all programs will use all these menus):
The Edit menu usually holds items like these:
The View menu has items like these:
The Window menu has items like these:
The Help menu has items like these:
Adding A Menu To A FormThe design process is completeits time to start adding menus to your new program. But when you sit down and start looking for the Menu tool in the toolbox, you find that there isnt one. Just how do you add a menu to a form? You use the Visual Basic Menu Editor. Youll get a basic introduction to the Menu Editor here, and well use it throughout this chapter. To add a menu to a form, select that form (that is, click on it), and open the Menu Editor by selecting the Menu Editor in the Tools menu. Or, you can select its icon in the toolbar (which has the tool tip Menu Editor). The Visual Basic Menu Editor appears in Figure 5.4.
Creating A New Menu To create a new menu, you only have to provide two essential items: the caption of the menu and its name. The Caption property holds the title of the menu, such as File, and the Name property holds the name youll use for that menu in code, such as mnuFile. Fill in the Caption and Name properties for your new menu now. Congratulationsyouve created a new menu. Now its time to add items to the new menu. Creating A New Menu Item We can add a new menu item, say, New, to the File menu weve just created. To do so, click the Next button in the Menu Editor, moving the highlighted bar in the box at the bottom of the Menu Editor down one line. If you just entered new Caption and Name values and left it at that, youd create a new menu, not a new menu item. So click the right-pointing arrow button in the Menu Editor now to indent the next item four spaces in the box at the bottom of the Menu Editor. Now enter the Caption (New) and Name, (mnuFileNew) values for the new menu item. The menu item youve just created appears in the Menu Editor below the File menu item and indented, like this: File ....New This means that we now have a File menu with one item in itNew. Thats how your menu system is displayed in the Menu Editor: as a series of indented items. For example, heres how a File menu with New and Open items, followed by an Edit menu with three items, Cut, Copy, and Paste, would look in the Menu Editor: File ....New ...Open Edit ....Cut ....Copy ....Paste Heres how to create a new menu system in the Menu Editor, step-by-step:
You edit the code for menu items just as you do for other controlsclick the menu item in the form under design (opening the items menu if necessary). This opens the menu items event handler, like this: Private Sub mnuFileNew_Click() End Sub Just add the code you want to execute when the user chooses this menu item to the event handler procedure:
Private Sub mnuFileNew_Click()
LoadNewDoc
End Sub
And thats itnow youve added a menu system to your program. Modifying And Deleting Menu ItemsYou think the program is perfect, but the users are complaining that they dont like having the Save As item in the Edit menu and want to move it to the File menu. Is that possible? Yes, using the Menu Editor. You can rearrange, add, or remove items in your menu with the Menu Editor, so open that tool now (as shown in Figure 5.4). Inserting Or Deleting Items In A Menu System To add a new item to a menu, or a new menu to the menu system, select an item in the Menu Editor, and click the Insert button. This inserts a new, empty entry into the menu just before the item you selected: File ....New ....Open ... Edit ....Cut ....Copy ....Paste
|
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. |