Solved

getting menu handle in Access 97 using API

Posted on 1998-02-17
3
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

733 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