Popup menu help -
Hi all.
I saw this code (below)in another forum. It creats a popupmenu when you right click on the form...just wondering how you make it apply to a text box, so that when you right-click on a text box, it will come up.
Any help much appreaciated.
Option Explicit
Const MENU_OPEN = 400
Const MENU_SAVE = 401
Const MENU_CHECKED = 402
Const MENU_DISABLED = 403
Const MENU_PRINT = 404
Const MENU_EXIT = 405
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type TPMPARAMS
cbSize As Long
rcExclude As RECT
End Type
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function CreateMenu Lib "user32" () As Long
Private Declare Function CreatePopupMenu Lib "user32" () As Long
Private Declare Function TrackPopupMenu Lib "user32" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As Long, ByVal y As Long, ByVal nReserved As Long, ByVal hwnd As Long, lprc As RECT) As Long
Private Declare Function TrackPopupMenuEx Lib "user32" (ByVal hMenu As Long, ByVal un As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal hwnd As Long, lpTPMParams As TPMPARAMS) As Long
Private Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
Private Declare Function InsertMenu Lib "user32" Alias "InsertMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
Private Declare Function DestroyMenu Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function SetMenu Lib "user32" (ByVal hwnd As Long, ByVal hMenu As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Const MF_BYPOSITION = &H400&
Private Const MF_STRING = &H0&
Private Const MF_POPUP = &H10&
Private Const MF_DISABLED = &H2&
Private Const MF_CHECKED = &H8&
Private Const MF_GRAYED = &H1&
Private Const TPM_LEFTALIGN = &H0&
Private Const TPM_CENTERALIGN = &H4&
Private Const TPM_LEFTBUTTON = &H0&
Private Const TPM_RIGHTALIGN = &H8&
Private Const TPM_RIGHTBUTTON = &H2&
Private Const TPM_RETURNCMD = &H100&
Dim hMenu, hSubMenu As Long
Dim pt As POINTAPI
Private Sub Form_Load()
Me.ScaleMode = vbPixels
hMenu = CreateMenu()
hSubMenu = CreatePopupMenu()
AppendMenu hSubMenu, MF_STRING, MENU_OPEN, "Open"
AppendMenu hSubMenu, MF_STRING, MENU_SAVE, "Save"
AppendMenu hSubMenu, MF_STRING Or MF_CHECKED, MENU_CHECKED, "Checked"
AppendMenu hSubMenu, MF_STRING Or MF_GRAYED, MENU_DISABLED, "Disabled"
AppendMenu hSubMenu, MF_STRING, MENU_PRINT, "Print"
AppendMenu hSubMenu, MF_STRING, MENU_EXIT, "Exit"
AppendMenu hMenu, MF_STRING Or MF_POPUP, hSubMenu, "File"
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, myX As Single, myY As Single)
Dim rc As RECT
Dim retcmd As Long
If Button = vbRightButton Then
pt.x = myX
pt.y = myY
ClientToScreen Me.hwnd, pt
retcmd = TrackPopupMenu(hSubMenu, TPM_LEFTALIGN Or TPM_RETURNCMD, pt.x, pt.y, 0, Me.hwnd, rc)
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
DestroyMenu hMenu
DestroyMenu hSubMenu
End Sub
Knowing when a popup menu is dismissed -
Obviously I know if the user has picked an item off of a popup menu because the proper menu handlers will be called but is there a way to know that the user has clicked outside the popup menu (thus dismissing it without a selection)? I'm highlighting some things when the popup menu is
calling popup menus from popup menus -
Okay this will probably seem pointless to most but what the hell, is it possible to call a TOTALLY different popup menu from another popup menu (and im not talking about submenus!)???
Another question, can you set the position on the screen where the popup menu appears???
Thanx
PopUp Menu Query -
Is it possible to have a popup menu when you don't have a menu at the top of the form.
All my menu items are on command buttons, and I would like to have a popup menu for my system tray icon.
how can i add a popup menu -
i need to make a new popup menu to a program.(not my vbproject)
Then in the popup menu.. lets say the caption is 'Help'.
I need to add a couple other popup menus.
So there is Help -> other1 -> menu 1
help -> other2 -> menu1
Help -> other3 -> menu1
andi ne
Strange popup menu with image -
Hay all,
If you try to add images to a form menu using the common API calls to do that it works nicely. Now if I make another menu and I set it's visiblity to false so i use it only as a popup menu, the menu icons simply vanish!! they disapear. I think I understand what is going on.
Exact positioning of popup menu at different resolution -
I have programmed my popup menu to appear at a particular location (just above the button that was clicked). Now I noticed that the location of popup menu changes when the screen resolution is different from the one on which it was designed/coded. I generally work at 1024x768. But when
Quickie Popup Menu - TextBox Popup Inhibit -
I did a quick popup menu (a four item listbox) for a stand-alone form
(no MDI parent). I want it to respond to a right-click, but it gets
overlaid by the Textbox popup menu.
How can I inhibit the Textbox popup?
Thanks,
John
Kill Popup Menu -
I have a treeview which gets the node on right click and displays a Popup Menu.
I want to be able to click other nodes even if the Popup Menu is displayed. Effectively ignoring the last click and loading the new Popup Menu Specifics for the Newly clicked Node.
Is this possible?
Popup menu problem -
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 t
Popup Menu when there's already a Menu up top </RESOLVED> -
I've previously added the code to get a Popup Menu on right-clicking a listbox, but that time it was the only menu on the form.
Is there a way to get two menus on my form or am I going to have to make another form and use it for the popup menu?
Make the Popup Menu go away! -
My program is using the Form.Popupmenu routine to create a popup menu, but when the user clicks somewhere out side of the popup menu's bounds, the menu does not go away. Is there a way to force it to disappear without using the API CreatePopupMenu instead?
Right click menu in VB -
Lately the right click Popup menu in vb has changed in my computer.
I no longer can select Definition thru the pop-up Menu.
Where can I reinsert it in the PopUp Menu.
Or how if i create a custom program, do i insert something in the PopUp Menu of another program.
Popup Menus on dual monitors -
Hi,
Using VB5 - If I use a right click popup menu and the main form is on the seconday monitor, the popup menu appears on the primary monitor and not at the mouse position.
Does anyone know a way round this or should I just use a form instead of a popup menu?
.
Detect when popup menu closes -
Is there any way to determine if a popup menu closes? What I have is a small window and I use a timer to keep it topmost of all programs on the computer. If I click a button to show a popup menu, the menu is gone when the timer fires. I want to turn off the timer until either a selecti
Strangely accessed popup menu -
To comply with a customer request, due to their pc occasionally ceasing to display all tray icons, I have modified the start-up routine (using app.PreviousINstance and sendmessage) of the application so that attempting to restart will display the popup menu normally accessed via clicki
Right-Click Popup Menu -
I know to create a popup menu, you use the menu editor and set the visible property to false. I would like to have the user right-click on a listbox item, and show the popup menu.
Could anyone just give me a simple example of how to make the menu visible on right-click?
Thanks!!
More Popup Menu Issues -
I have a MDI app which I have just implemented right click popup menus. The popup menus work fine but I've noticed that when I open a child form containing a popup menu the menu on my parent form disappears. How can I retain the menu on my parent form?
Simulate clicking on a right-click menu (popup menu) -
Hi all,
I want to simulate clicking on a right-click menu (popup menu).
How can I do it? What type of MESSAGE should I post?
The problem is that the popup-menu should not be opened (just the CLICK event of menu item should be done), or the pop-up menu should be invisible.
Thank
Problem displaying popup[Urgent] -
I have a problem in showing a popup menu on a relative position. I have a button, when the user clicks on the button the popup menu will be displayed below the button(Like drop down menu). For that i used the buttons top and left property to set the x and y coordinates for the popupmen
PopUp Menu Again -
This is a lengthy message but is worth looking at...
I have been trying to figure out the problem of doing a popup menu on a modal form the past few days. There are some strange behaviour that occurs to my program which I think progrmammers might be interested to know. I try calling
excel 2007 customize popup menu -
Hi,
Not sure if this has been asked although I've searched and not found anything.
Is it possible to customize the popup menu (I'm thinking no, but hoping yes)? If NO, how to create my own popup menu to replace the built-in one.
Thkx
Menu Wont pop-up in systray -
Sups all,
In my last app i used a popup menu in the systray and all worked perfect.
In my correct app, I wanna use a popup menu in the systray too, but it just wont popup. (i can minimized to systray but cant popup the menu. Clicks on the icon wont do nuthin.)
i'm using the same cod
Right Click Popup Menu Over and Over -
I have a treeview control and I want the ability to right click on an item and have a popup menu show up. I can get this part to work the next part is where I have the problem. While the popup menu is still up I cannot right click on a different item until the the popup is addressed. I
Help Please ! Popup bug ;( -
Hi !
I have a great problem here and it's really bugging me off !
Moreover I have to find it pretty quickly because i have more work to do.
So here is the problem :
I'm using MDI ... In that MDI Main Window I have a menu (File, Window, About ...), that i build with the menu edi
popup menu in textboxs -
yea hey, when u right click in a textbox(with text in it) it popups witha menu, but i have a code in there for mouse down for rightclick, but then the popup menu comes up, how can i stop the menu from not poping up/
creating popup menu with pictures. -
im looking to make a popup menu, when a button is pressed a menu will popup with a few submenus in thos submenus will be smiley pictures, and next to the pictures the text ( i.e. ) for what to type to make the smiley. any ideas on how i can setup a popup menu with pictures? Thanks!
Popup menus from tray icons..... -
Okay i got a problem, i have got an icon into the tray menu, and a popup menu to open when it is clicked on, the only thing is, is that when i click somewhere else on the task bar the popup menu is still open, anyone know how i can change that???
Another thing is is there a way of mak
Block Popup Menu -
Hi,can someone please tell me about block popup menu..i really want to know..
It always noticed "please disable your pop up blocker to view" or the popup is blocked even a Block Popup is unchecked ..
I dont understand why me must prevent popup from appearing..sometimes it g
Popup Menu Position -
I created a popup menu through API, and I want it to act a certain way when it's near the edge of the screen. Usually, when you have a popup menu appear near the edge of the screen, if the menu is wider than the distance it popped from the edge, the menu will pop out from the opposite
another quetion.. -
hi all
any one know a way to get bounding rectangle of a popup menu? i've used GetWindowRect API with hWnd param is popup menu handle, but hasn't return correct popup menu bounding rectangle.. i dont know why? does any one help me out?
thanx for advice..
angelfire
popup menu & subroutine -
Is it possible to call a subroutine and specify the arguments of that subroutine from a popup menu even though the arguments may be different? I'm trying to clear textboxes with the subroutine. Lets say I have four textboxes. The subroutine requires a number to tell it which textbox to
Popup Menu on Usercontrol Pls help !!! -
Hi everyone
How do I create a popup menu on usercontrol.
In Usercontrol VB allows me to use Menu Editor to add a menu to Usercontrol. But when I call the menu as something like usually in the Form,
Me.PopupMenu mnuMyFile
I can't use Me. here can I ?
Example would be great
Add popup menu to another program. -
Just an idea... Would it be possible to add a popup menu to another application? For instance, right click in an instant messenger box and get a menu of pre-defined text strings.
Textbox in Popup Menu -
I would like to put a text box in a right-click pop-up menu and allow the user to enter some information into it.
If you've ever used MS Access and right clicked on a cell in a table, you know what I'm talking about. (The filter option in the right-click menu) If you haven't, then b
Popup menu, Context menu dynamic creation -
Hi everyone,
i used the google search and the forum search but i didnt find any suitable result.
What i want to do:
i want to display a popup menu which is dynamic created from an xml file. i read the xml file to my own private type structure and now i want to display a popup menu
Tooltip popup for menu items -
Is there a way to have a box popup when the mouse has been
over a menu item for more than 1 second?
I would like to show the user the whole file path, and I don't
prefer to put the occassional 60 chars into a menu item's caption.
Thank you for any help! =0
Positioning of PopUp Menus -
I've got a ListView that when a user Right-Clicks over a selected entry a PopUp Menu appears.
On the same ListView if the user presses the Windows Right-Click Key on the Keyborad (The one next to the right Windows Key) the PopUp Menu appears.
However the position of the PopUp Men
right click popup on listbox question -
do i basically create a popup using the vb menu editor?
but then i have a ListView1 on my form, and i want it to make the menu popup when i right click on an item in the first list of the listview
any ideas guys?
Popup menu on RIGHT CLICKof exe file -
HI all,
In my application i want that the popup menu will appear when the user will RIGHT CLICK or MIDDLE CLICK on the EXE file..How can i do this?
And can i add some options in the default popup menu which appears on RIGHT CLICKING a file?
Help.....
Anita
Task Tray Popup menu question -
VB6
Hi -
I'm using pretty standard code to create a popup menu that shows when you click the task tray icon for my app.
(ShellNotifyIcon, etc)
However, I'm finding that if you activate the menu, and click anywhere else on the screen, the menu stays up.
In fact, the only way t