Results 1 to 3 of 3

Thread: Right Click Menus?

  1. #1

    Thread Starter
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249

    Post

    Is it possible to make a menu popup within vb when you right-click of something. Same idea as when you rightclick the windows desktop, but just more customizable? if so is there a tutorial for this? can someone help me out? thanx!

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Sure. Add a menu to your form which has the top level (which I've called mnuFirstItem) enabled but not visible. Then add as many menu items under that one as you like, all of them being visible (don't worry they won't show up until you want them to). Then add code like this to your form and any object you want to have popup help.
    Code:
    Option Explicit
        Private ControlClicked As Control
    Private Sub MyObject_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
    
        If Button = vbRightButton Then
            Set ControlClicked = MyObject
            PopupMenu mnuFirstItem
        End If
        Set ControlClicked = Nothing
        
    End Sub
    ------------------
    Marty

  3. #3
    Member
    Join Date
    Dec 1999
    Posts
    37

    Post

    Yes, it is possible to make a pop-up menu! In the Menu Editor, it should look like this one.

    PopUp
    ...Blue
    ...Green

    PopUp displays a pop-up Menu. When you right-click the mouse, pop-up menu appears.

    Code:
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbrightButton Then
            Call PopupMenu(mnuPopUp)
        End If
    End Sub
    
    Private Sub mnuBlue_Click()
        Label1.BackColor = vbBlue
    End Sub
    
    Private Sub mnuGreen_Click()
        Label1.BackColor = vbGreen
    End Sub
    Hope this helps.

    Ruchi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width