Solved

getting menu handle in Access 97 using API

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

861 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