You are on page 1of 3

Lesson 2 : Adding Menus to a Program

For our next lesson, we will try to add additional features in our first
program. We will make a variety of background colors to our Click to Win
interface by adding a color menu that is placed on the upper left corner of the
form.

Click the Background


menu and a drop-down
menu of colors with
shortcut keys will
appear.

To create this feature we need a Visual Basic tool called the Menu Editor.
In adding menu to a form, we must first open the Click to Win project file.

To open the Menu Editor, do any of the following :

 Click Tools from the Standard toolbar and choose Menu Editor.
 You can also press Ctrl + E as a keyboard shortcut.
 The Menu Editor will appear.

Chapter Three : Lesson 2 ( Adding Menus to a Program )


To create the Background menu for the program, follow the steps below.

 Write a menu named ‘Background’ in the ‘Caption’ textbox. Press the TAB
key to move to the next textbox.

 Note : The Background menu is the top level menu


and the rest are sub-menus.

 Press the Next button.


 Follow these same procedures in writing the rest of the menus.

 Note : Insert the word ‘mnu’ before each word in the


‘Name’ textbox.

Use the given Menu names and Captions as shown in the table below.

CAPTION NAME SHORTCUT


&Background (top level) MnuBackground
Green MnuGreen Ctrl+G
Blue MnuBlue Ctrl+B
Red MnuRed Ctrl+R
Violet MnuViolet Ctrl+V
Orange MnuOrange Ctrl+O
Pink MnuPink Ctrl+P
Yellow MnuYellow Ctrl+Y

Assign a shortcut for the menu options as shown in the table above. Click
a Shortcut from the Shortcut textbox. To do this, select the menu option from
the list in the Menu Editor then choose a shortcut from the Shortcut pull-down
list box.

 Next, we need to indent the rest of the menu options to define the sub-
menu for the top level menus :

To indent a menu (…Green), click the Indent button.


An Indented menu u( …Green) is the sub-menu of the Top level menu
(Background).
A top level menu should not be indented. To remove the indention (…), select
the menu then press the Decrease indent button.

Chapter Three : Lesson 2 ( Adding Menus to a Program )


 Write another top level menu name ‘About’ (mnuAbout) and its sub-menu
named ‘The Author’ (mnuTheAuthor as indicated in the table).

CAPTION NAME SHORTCUT


&About (top level) MnuAbout
The Author MnuTheAuthor Ctrl + T

 Write another top level menu named ‘Close’ (mnuClose).

CAPTION NAME SHORTCUT


&Close (top level) MnuClose

 We have now created all the menus needed. Press the OK button. Your
program should look like the figure below after completing the exercise.

The three
menus we
have created

LESSON SUMMARY :

In this lesson, we learned how to create menus with the purpose of


enhancing the functionality of our program. A Menu Editor is a graphical tool
that generates and manages menus in your program. It gives the menus its
properties such as Name, Caption, Shortcut Key and Level. To make a
menu stay as a top level menu, we must not click the Indent button. Clicking
the Indent Button, a top level menu becomes a sub-menu. A sub-menu
becomes a top level menu if you click the Decrease Indent button. Menus
must have a Name and a Caption. You can also assign shortcut keys to a
menu. Deleting and Inserting menus in your project are also possible using
the Menu Editor.

Chapter Three : Lesson 2 ( Adding Menus to a Program )

You might also like