Ross Sheppard High School
Computer Programming 20
Student Learning Guide
The Popup Menu Program
When you have finished this project, you will be able to:
modify a menu
create a fly-out menu
create a popup menu
Create a new folder called Popup Menu on your personal drive.
COPY all of the files from the Color Folder to the Popup Menu Folder.
Start Visual Basic and open the program from the Popup Menu Folder.
Save the form and the project as Popup Menu Program.
Think about what the menu selections looked like in the Colors Program. Run the
program to refresh your memory.
In the Colors Program, you learned how to create menu items and write code for them. In this project, you will
learn how to make fly-out windows and popup menus.
The first thing you need to do is to modify the current menu structure. Make sure
you are in the Form View window.
Open the Menu Editor, and you will see what the current menu items look like.
Insert a new menu item between File and Red:
Indent the color choices by clicking the right arrow.
Click OK, then run your program.
When you select File on the menu bar, the Colors option should be visible with
an arrow indicating there is a fly-out menu.
Hover the mouse on the Colors option to see the fly-out menu.
Try all of the menu items - they should work the same way as they did in the Colors
Program.
Using fly-out menus is a good method of making the Menu Bar menus shorter and
easier to read.
With the implementation of Windows 95 and later versions, Microsoft allowed for
the use of the right mouse button to provide quick access to certain menus for the user. By right clicking on an
object, a user can call up a menu that is specific to that object. This is called a popup menu.
A popup menu is created by adding some code to the code portion of the program,
on the Form object.
Enter the Code View window.
Choose the Form Object and the MouseUp Event.
Next, add the following code to the Form_MouseUp procedure that was added.
Run your program and right click the mouse anywhere on the form where there is
no other object. The popup menu should appear.
Try each of the popup menu items - they should all work exactly as the items in
the Menu Bar.
From this point on, you must include context sensitive and fly-out menus when
appropriate to enhance the usability of a program.