Page 220 - Open Soource Technologies 304.indd
P. 220
Event Driven Programming
Write a program Creating Menus with the Menu Editor
Menus are added to Windows applications using the Tool, Menu Editor (Ctrl+E shortcut) in VB6.
The Menu Editor allows you to create menus by typing the Caption and Name of each menu item
and initialize menu items by setting properties for each menu item in the Menu Editor dialog
box (see Figure 9.11). Referring to figure one, the menu item that has the focus is the item selected
in the list in the bottom half of the Menu Editor dialog. Menu items at the extreme left edge are
top-level menu items and each level of indentation represents an additional level of nesting.
Figure 9.11: The Menu Editor is Used to Design Menus in VB6.
From Figure 9.11 we can see that a top-level menu named Popup is selected. The caption that
will be displayed is the value in the Caption field, in the example this is “Popup”. If we were
to add an ampersand to the value of the Caption property immediately before the first P in
popup—&Popup—then the first P in popup would be the hotkey for the Popup menu. When
the menu is displayed it would appear as follows: Popup. Further if the hotkey P were used
then pressing Alt+P when the application containing the popup menu were run would cause
the Popup menu to be displayed.
Other properties for the Menu Editor are pretty intuitive. You can use the VB6 help if you are
unfamiliar with other Menu Editor properties.
If we were to check the Visible property for the menu shown then the Popup menu would
appear as shown in Figure 9.12 (when displayed).
214 LOVELY PROFESSIONAL UNIVERSITY