You are on page 1of 30

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name of the faculty: G. Radha
Designation : Lecturer
Branch : CCP
Institute : 026 - SG Govt. Polytechnic, Adilabad
Year / Semester : III Year / V Semester
Subject : Visual Basic – I
Subject Code : CCP - 503
Topic : Understand Menus and Common
dialogue control .
Duration : 50 Mts.
Sub Topic : menus – popup menu , check marks
etc.,
Teaching Aids : Animations & Images
CCP503.16 1
Recap

 How to create Shortcut Keys, Access Keys and


Separators for pull down Menus.

CCP503.16 2
Objectives:
Upon completion of this period, the student will
be able to understand about

 Creating Pop-up Menus.


 Using Check marks in Menus.
 Making Menu Controls Invisible.
 Enabling and disabling Menu Commands.

CCP503.16 3
Pop-up Menus

 A Pop-up Menu is a floating Menu, that is displayed


over a Form independent of the Menu Bar.

 Pop-up Menus are also called Context Menus,


because the item displayed on the Pop-up Menu
depend on where the pointer is located, when the right
mouse button is clicked.

CCP503.16 4
Popup Menu Method

 Any Menu that has at least one sub menu can be


displayed as Pop-up Menu.

 To display a Pop-up Menu, we use the Popup Menu


method.

CCP503.16 5
Syntax of Pop-up Menu Method

 [form.] PopupMenu MenuName[,Flags[,X[,Y]]] as


Pop-up Menu.
 Menu Name is the Name of the Menu Item for
which Popup Menu is displayed.
 There are three optional arguments to the
PopupMenu method i.e., X,Y and Flags.

CCP503.16 6
Syntax of Pop-up Menu Method

 We use X and Y arguments to specify the X and Y


coordinates where the Popup Menu is to be
displayed.
 We use Flags parameter to further define the
location and behavior of Pop-up Menu.

CCP503.16 7
Example of Pop-up Menu

 Any Menu can be displayed as a Pop-up Menu at


run time provided it has at least one Menu Item.

 The following code displays the Colors Menu when


the user clicks right mouse button over the Form at
run time.

CCP503.16 8
Example of Pop-up Menu

Private Sub Form_MouseDown(Button As Integer, Shift As


Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu MnuColors
End If
End Sub

CCP503.16 9
Example of Pop-up Menu

CCP503.16 10
Using Check Marks

 In some programs we may require check marks


to be placed in the menu items.
 By default a checked property is set to “ FALSE”
 To place a check mark in a menu item, the
checked property is set to “TRUE”

CCP503.16 11
Example of Check Marks

 The following example code to be entered in the


Form_Load() event, to put a Check Mark in the
Menu Item Red
MnuRed.Checked = True
 The following code to be entered in the
Form_Load() event, to Uncheck the Menu Item
Red
MnuRed.Checked = False

CCP503.16 12
Example of Check Marks When
Checked

CCP503.16 13
Example of Check Marks When Un-
Checked

CCP503.16 14
Enabling and Disabling Menu Commands

 All Menu Commands have an Enabled property,


and when this property is set to False, the Menu is
disabled and does not respond to user action.
 A Disable Menu Control appears grey, like the
Close Menu Item.

CCP503.16 15
Enabling and Disabling Menu Commands

For Example, the following statement in


Form_Load() procedure disables the Exit menu
item on the File Menu of the Color / Size
program.
MnuExit.Enabled = False

CCP503.16 16
When Menu Item is Disabled

Disabled

CCP503.16 17
Enabling and Disabling Menu Commands
 Disabling a Menu Title in effect disables the entire
Menu, since the user can not access any Menu
Item without first clicking the Menu Title.
 For Example, the following code in Form_Load()
procedure disables the Colors Menu of the Color /
Size Program.
MnuColors.Enabled = False

CCP503.16 18
When Menu Title is Disabled

Disabled

CCP503.16 19
Making Menu Controls Invisible

 When a Menu Item is disabled by setting Enabled


property of Menu Item to False, then it is dimmed
and can not be selected.
 But it is still Visible and the Menu Items are seen
 To hide a Menu Item completely, use the following
code in Form_Load() procedure of Colors program
to make the MenuItem Exit invisible at Run Time.
MnuExit.Visible = False

CCP503.16 20
When Menu Item is Invisible

Exit Menu Item


is not Visible

CCP503.16 21
Making Menu Controls Invisible

 The whole Menu is made invisible by setting


Visible property of the Menu’s Title to False.

 The following code to be entered in the


Form_Load() procedure to make the Colors Menu
invisible.
MnuColors.Visible = False

CCP503.16 22
When Menu Title is Invisible

Colors Menu
Title is not
Visible

CCP503.16 23
Summary
 Creating Pop-up Menus.
 Usage of Checkmarks in Menus.
 Enabling and disabling Menu
Commands.
 Making Menu Controls Invisible.

CCP503.16 24
THANK YOU

CCP503.16 25
Quiz

• A floating Menu that is displayed over


a Form independent of the Menu Bar is
A) Pop-up Menu
B) Sub Menu
C) Cascading Menu

CCP503.16 26
2. Check mark can be placed on a Menu
Item using _____ property.
A) Enable
B) Check
C) Visible

CCP503.16 27
3. The property used to hide the Menu Item
completely is
A) Enable
B) Visible

CCP503.16 28
Frequently Asked Questions

1. What is Pop-up Menu ? Write syntax for


creating Pop-up Menu.
2. What is the difference between Enabled
property and Visible property of Menu
Control?
3. What are Check marks in a Menu
Control?

CCP503.16 29
Assignment

1. Create a menu structure to show the use of


popup menu’s ,checked Menu item

CCP503.16 30

You might also like