Solved

getting menu handle in Access 97 using API

Posted on 1998-02-17
3
232 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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…

705 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