Click to See Complete Forum and Search --> : How do I show a menu?
Desire
Nov 5th, 1999, 09:10 PM
I would like to show my File Menu when the user clicks on a command button, how would I go about doing this?
Thanks
Desire
rino_2
Nov 5th, 1999, 09:52 PM
I'm not too sure what you mean but this might help???
set the file menu's Visible property to false
and put this code behind the button:
private sub cmdGo_Click()
file_Menu.visible = true
end sub()
Hope this helps!
MartinLiss
Nov 5th, 1999, 09:56 PM
Assuming your file menu has an access key (an underlined letter) of "F", then SendKeys "%{F}" will do what you want.
------------------
Marty
ShadowCrawler
Nov 6th, 1999, 01:16 PM
Or, you can just show a temporary copy of the menu, using the PopupMenu method.
Private Sub Command1_Click()
Me.PopupMenu mnuFile
End Sub
------------------
(¯`·.¸¸.·´¯`·->ShadowCrawler<-·´¯`·.¸¸.·´¯)
Teenage Programmer
Visual Basic, HTML, C++, JavaScript
http://welcome.to/X12Tech
Email: craigkovatch@compuserve.com
ICQ#: 9872708 (http://wwp.mirabilis.com/9872708)
Yonatan
Nov 7th, 1999, 12:44 AM
Here's code I just made which entirely emulates the menu popping up:
Option Explicit
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetMenuItemRect Lib "user32" (ByVal hWnd As Long, ByVal hMenu As Long, ByVal uItem As Long, lprcItem As RECT) As Long
Private Declare Function HiliteMenuItem Lib "user32" (ByVal hWnd As Long, ByVal hMenu As Long, ByVal wIDHiliteItem As Long, ByVal wHilite As Long) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
Private Const MF_BYPOSITION = &H400&
Private Const MF_HILITE = &H80&
Private Const MF_UNHILITE = &H0&
Private Sub Command1_Click()
Dim hMenu As Long, RCMenu As RECT, PT As POINTAPI
Const MenuNumber = 0 ' Should be 0 for first menu in menu bar, 1 for second, etc.
hMenu = GetMenu(hWnd)
Call GetMenuItemRect(hWnd, hMenu, MenuNumber, RCMenu)
PT.X = RCMenu.Left
Call ScreenToClient(hWnd, PT)
Call HiliteMenuItem(hWnd, hMenu, MenuNumber, MF_BYPOSITION Or MF_HILITE)
Call PopupMenu(Menu:=mnuFile, X:=ScaleX(PT.X, vbPixels, ScaleMode), Y:=0) ' Menu:=YourMenuName
Call HiliteMenuItem(hWnd, hMenu, MenuNumber, MF_BYPOSITION Or MF_UNHILITE)
End Sub
------------------
Yonatan
Teenage Programmer
E-Mail: RZvika@netvision.net.il
ICQ: 19552879 (http://www.icq.com/19552879)
MartinLiss
Nov 7th, 1999, 11:46 AM
The problem (or the benefit depending on your point of view) with PopupMenu, is that it pops up where your cursor is. PopupMenu is usually used for "What's This?", context sensitive, type help, where when the user right-clicks an object, that object issues a PopupMenu that displays a "What's This?" menu item. When that menu item is clicked, help for that item is displayed. If you want to know the details of how to do it, email me.
------------------
Marty
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.