PDA

Click to See Complete Forum and Search --> : Right Click Menus?


Smie
Dec 3rd, 1999, 04:04 AM
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!

MartinLiss
Dec 3rd, 1999, 05:17 AM
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.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

Ruchi
Dec 5th, 1999, 12:04 PM
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.



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