VB6 Tutorial 60: Popup menu

Posted On 2018-06-02 by VB6Boy
Keywords: visual,basic,vb6,visualbasic,tutorial,basic,beginner
Tags: VB6 Tutorials 
Views: 39

Title Uploaded Size
popupmenu.zip 6/9/2018 6:29:25 AM 1,104


Looking for the more of the VB6 Tutorial? Here is the tutorial index.

Most commercial software products have popup menus (also known as context menus) as they can make the application more user-friendly and powerful.

When you right click on windows desktop, a popup menu appears. Visual Basic 6.0 provides a Popup menu method that you can use in your program to show the popup menu on the form's surface.

To use the Popup menu method, you first need to create a menu. For example, create a menu with the name "View". See the example given below.

popup menu example

The PopupMenu method

Syntax

PopupMenu Menu, [Flags], [X], [Y], [DefaultMenu] 

Note: Arguments in [ ] brackets are optional.

Now write the following code in the form's MouseDown event to invoke the popup menu.

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbRightButton Then
        PopupMenu mnuView   'PopupMenu is a method
    End If
End Sub

popup menu example

If you need only the popup menu but not the menu bar, set the Visible property of the menu control to False in design time.

Looking for the more of the VB6 Tutorial? Here is the tutorial index.


About the Author

has posted a total of 101 articles.


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:54.159.91.117

Before you can post, you need to prove you are human. If you log in, this test goes away.


Code Links