I 've created a popup menu but i could'nt find a way to execute the instructions related to it.( i want to load another form when i click on the popupmenu)
I have tried the click, double click, mouse up mouse down but nothing works please help
You should have a menu in a form with visible property set to false for top level.
You should have at least one submenu item (which should be visible= true).
If top level menu is "mnuFather" and submenu is "mnuSon",
to show it, you can have the
popupmenu mnuFather
code in the mouseUp event of form (that is: it will trig on clicking
on form) or any other control, but if it is a control which has
its own popup defaulty menu (like textboxes) you should first
suppress the default menu this way if you want it to appera on right click:
Code:
Option Explicit
Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
if button = vbrightbutton then
Text1.Enabled = False
Call Text1_MouseUp(Button, Shift, X, Y)
end if
End Sub
Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
if button = vbrightbutton then
PopupMenu mnuFatther
Text1.Enabled = True
end if
End Sub
'
'While code to be executed should be palced in mnuSon_click
event
Last edited by Cimperiali; July 28th, 2002 at 04:37 AM.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
I have two listviews on the screen for which I created a popupmenu.
The menu display on the right mousebutton (mouseup event) and I can run the menuitems without a problem.
The problem is that when I right-click on the incorrect item in the listview and I want to select another item I must first left-click outside the popupmenu and then right-click on the listview item to get the popupmenu.
While the popupmenu is open the mouseup event doesn't seem to run until the popup is closed.
What I would like to achieve is to be able to keep right-clicking on items in either of the listviews and the popupmenu must keep closing and opening where ever I'm right-clicking.
Would this be possible without left-clicking outside the menu first.
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
You could add a "Close" sub-menu that does nothing. This will at least allow them to not have to move outside the popup menu window. Just clicking it will cause the popup to disappear.
If I understand right, you would like to get the underlying value from the listview to appear in the popup menu.
I had the same problem you described where you had to left click first then right click. I solved this by using a formwide variable and placing the clicked item value from the listview into the variable in the ItemClick Event of the listview control. I believe the Item Click Event occurs before the mouse events. In the MouseUp or MouseDown Event I had the code for the PopUp Menu and I used the formwide variable to changre the PopUp menu contents to show the item I had right clicked.
If the above doesn't work, its because I am going from memory as I haven't done this in awhile. In a couple of days when I can get back to my puter I will research how I did this and update you on it. - Anyway I hope this helps.
To John G Duffy - This is how I currently use it, with a Close Menu submenu.
To RGregoire - No, I don't need to add the value selected on the listview to the menu, the menu has fixed menuitems. Might be a nice way to get a heading into the popupmenu though.
To Cimperiali - It's not working for what I'm trying to achieve. For instance, If I right-click on Item No. 1 the popupmenu opens. Now without selecting anything on the menu I right-click on Item No 5. Nothing happens. You must first select a menu option or left-click outside the menu to close it. Right-clicking on Item No 5 now will open the popupmenu.
What I'm trying to achieve is the behaviour like the standard popupmenu of a textbox. If you right-click anywhere inside the textbox the standard textbox popup opens. Then without selecting anything in the popup you right-click somewhere else in the textbox the open popup will close and reopen there where you right-clicked.
What seems to be happening is that the mouseup event will trigger and open the popup. Right-clicking again doesn't trigger the mouseup event again before the popup menu is closed by either left-clicking outside the menu or selecting a menuitem. It seems that once the popup has opened the right mouse button goes dead and only after the popup has closed comes back to life.
What you want should be default behavior.
You can test with this small example:
RightClicking in list1 or list2 will popup the
menu where you clicked, even if menu was already
out.
You sure is not some code you are executing meanwhile?...
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
I also thought it should be default behaviour but alas, can't get it to work.
Thanks in any case guys. It's not serious so if someone does stumble on a solution please post it. Maybe there's other people out there with the same question.
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 2 Then
PopupMenu menu, vbPopupMenuRightButton
End If
End Sub
have one of you try that? (vbPopupMenuRightButton = 2)
Is that what you want?
Thanks for remembering of flags existence
(I forgot them).
Five stars from me too.
'
A note:
Still I cannot understand why this way it works:
matter was:
While the popupmenu is open
the mouseup event doesn't seem to
run until the popup is closed.
That is: a matter related on a strange persistence of
the menu popup while trying to right click on another
element of a listview.
Or did I understood it wrong?
Have a nice day,
Cesare
'**************************************
Code:
From msdn
vbPopupMenuLeftButton = 0
(Default) An item on the pop-up menu
reacts to a mouse click only when you
use the left mouse button.
vbPopupMenuRightButton = 2
An item on the pop-up menu reacts to
a mouse click when you use either the
right or the left mouse button
Last edited by Cimperiali; August 1st, 2002 at 02:58 AM.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.