-
Hi,
I have a popup menu in my app. It works, but not the way like other popup menus in Explorer or other windows apps.
Basically when the popup menu is open I can't right-click somewhere else on the form and re-display that menu at mouse point. I have to either left-click one of the menu options or left-click somewhere else to make the menu dissapear and then when the menu is off I can right-click again to make it re-apear.
Example:
Let's say, you're on windows desktop. No matter how many times you right-click, a NEW menu pops up at current mouse position. You don't have to close it, you just right-click again somewhere else and the current menu closes and the new one appears. I want the same thing in my app.
Thanks for your help.
-
you can set a right mouse button setting to click. I'm confushing myself, but this will let the right mouse button do what you want! this is a flag in the popupmenu function:cool:
-
-
I think this is always so in a VB program. Maybe if you create the menus with the API the problem is solved. I'm sure V(ery) Basic will give you his menu example that uses the API if you ask him.
-
Unfortunately, my app doesn't do that yet. But, as always, I will respond to consumer demands and subclass mouse events.
Rest assured I will die trying. Well, metaphorically. Maybe not even that.
-
no, vb is set for leftbuttondefault. I've giving this tip to someone else, it works for him. in the PopupMenu Function, set the flags to vbRightButtonDefault (or something like that, use MSDN)
-
It's actually vbPopupMenuRightButton gwdash, but the idea of what you were talking about works. Here's an example:
Code:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then PopupMenu mnupopup, vbPopupMenuRightButton
End Sub
-
Does anybody know how VB does that? Because Windows doesn't send any mouse messages while a menu is up, so how can it tell when a button has been clicked?
If somebody has any ideas, please say, because I'd like to add this functionality to my project.
Thank you,
El Maestro
-
V(ery) Basic, you could do something like this:
Code:
Dim clicked As Integer
Private Sub Form_Load()
clicked = 0
End Sub
Private Sub Command1_Click()
clicked = 1
End Sub
Private Sub Command2_Click()
If clicked = 1 Then MsgBox "Command1 has been clicked!", vbCritical
End Sub
-
<?>
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
-
So that means that if I show the menu when the mouse button is released, then it'll receive mouse messages.
For a change that makes sense!
Thanks, but why did he say 'Joe'?
Gee. It's getting a little late now so I'd better go. Thanks,