jdn
asked on
getting menu handle in Access 97 using API
I want to do some stuff with the Office Developer's Toolkit that comes with the MSDN CDs.
The functions I want to use (GetMenuString, GetMenuItemID..)
all require the menu handle as input.
In Access 97 with the database open, how do you get the handle to the Access Menu bar?
The functions I want to use (GetMenuString, GetMenuItemID..)
all require the menu handle as input.
In Access 97 with the database open, how do you get the handle to the Access Menu bar?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK, I'll try that. I found a different solution but I'm sure I'll need something like this again.
thanks
thanks
Declare these function
Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long
Declare Function GetActiveWindow& Lib "user32" ()
Here is the function:
Function EnableSubMenu(MenuNr As Integer, SubMenuNr As Integer, Enable As Integer)
On Error Resume Next
Dim hwnd As Long
Dim TopMenu As Long
Dim SubMenu As Long
hwnd = GetActiveWindow()
TopMenu = GetMenu(hwnd)
SubMenu = GetSubMenu(TopMenu, MenuNr)
If Enable Then
Exec = EnableMenuItem(SubMenu, SubMenuNr, 0 Or &H400)
Else
Exec = EnableMenuItem(SubMenu, SubMenuNr, 1 Or &H400)
End If
End Function