Solved

getting menu handle in Access 97 using API

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

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.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

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