Hi,
I want to know if it's possible (probably!) when a user clicks on a form (anywhere) to will display a menu, just like the menu's when you right-click, for example in this page).
Anyone suggestions? There must be a way to do that!
Thanks!
Jop
Printable View
Hi,
I want to know if it's possible (probably!) when a user clicks on a form (anywhere) to will display a menu, just like the menu's when you right-click, for example in this page).
Anyone suggestions? There must be a way to do that!
Thanks!
Jop
Create A menu using Menu Editor and make it invisible (Visible = False). Then use this code:
HTHCode:Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'//works only if user clicks the right button
If Button = vbRightButton Then
Me.PopupMenu mnuPopUp
End If
End Sub
[Edited by QWERTY on 03-31-2000 at 06:35 PM]
Sure, use the PopupMenu function. Here is an example from MSDN.BTW, I don't know why but MS Help is often poorly written as in the example where the "magic number" 2 is used rather than the built-in constants for the mouse buttons which are:Code:PopupMenu Method Example
This example displays a pop-up menu at the cursor location when the user clicks the right mouse button over a form. To try this example, create a form that includes a Menu control named mnuFile (mnuFile must have at least one submenu). Copy the code into the Declarations section of the form, and press F5.
Private Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu mnuFile
End If
End Sub
vbLeftButton 1 Left mouse button
vbRightButton 2 Right mouse button
vbMiddleButton 4 Middle mouse button
Thanks guys, you've helped me alot!
Jop