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
Printable View
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
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!
Assuming your file menu has an access key (an underlined letter) of "F", then SendKeys "%{F}" will do what you want.
------------------
Marty
Or, you can just show a temporary copy of the menu, using the PopupMenu method.
------------------Code:Private Sub Command1_Click()
Me.PopupMenu mnuFile
End Sub
(¯`·.¸¸.·´¯`·->ShadowCrawler<-·´¯`·.¸¸.·´¯)
Teenage Programmer
Visual Basic, HTML, C++, JavaScript
http://welcome.to/X12Tech
Email: [email protected]
ICQ#: 9872708
Here's code I just made which entirely emulates the menu popping up:
------------------Code: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: [email protected]
ICQ: 19552879
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