Solved

getting menu handle in Access 97 using API

Posted on 1998-02-17
3
263 Views
Last Modified: 2006-11-17
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?
0
Comment
Question by:jdn
3 Comments
 
LVL 5

Accepted Solution

by:
cekman earned 100 total points
ID: 1968733
I hope I'm not posting this twice - it didn't take the first time..
You no longer retrieve menu handles in Access97 - they don't exist. You now use references to commandbars. The following is from page 687 of The Access Developer's Handbook:

To use an existing CommandBar:

Dim cbr as CommandBar
Set cbr = CommandBars("Menu Bar").controls("View")._
  CommandBar.Controls("Database Objects").Commandbars

For more info search help on commandbar objects.

CEkman
0
 

Expert Comment

by:johnsen
ID: 1968734
I use API calls.

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



0
 

Author Comment

by:jdn
ID: 1968735
OK, I'll try that.   I found a different solution but I'm sure I'll need something like this again.


thanks


0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now