-
I'm using the mouse-down event of a form for a few different purposes. My code is written so that if the user selects the right mouse button, a PopUpMenu appears. The problem is, it won't go away until several clicks of the left mouse button. :(. Any help out there. Thanks in advance. :) P.S. This is an MDI application.
-
Take a look at this thread which answers your queston. Not sure if it will work the same for an MDI form though.
-
<?>
Code:
'code is compliments of ameba at ExpertsExchange
'make a popup menu just like the one's in windows
'appear at the right click of your mouse as long
'as your right click is on the form
Option Explicit
Private Sub Form_Load()
mnuPop.Visible = False
End Sub
'
'allow users the ability of win keyboard menu key
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 93 Then
'fire up the popup menu
PopupMenu mnuPop, 2, 60, 60
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
'fire up the popup menu
PopupMenu mnuPop, 2, X, Y
End If
End Sub
-
Use this:
Code:
'Declaration
Public Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
set this form as current window, otherwise popup
'menu will stay on the screen even after you click
'outside it
Call SetForegroundWindow(Me.hwnd)
PopupMenu frmMain.mnuconfigure
End Sub
-
Who ressurected this old thread?
-
I took me a long time to find out how to acomplish it so I thought I'd post it anyway, incase anyone searches for a way to remove the menu.
Plus, I didnt even look at the date :)
-
I've had similar problems, and I solved it with this (even though it sounds somewhat unconventional)
Make the last menu item of your popup menu and item called
Cancel Menu
Put nothing in its click event.
Bring the menu up, and click on Cancel Menu.