Strange functions

D

David

I am modifying a system written in the time of the ark.
Sprinkled throughout the code are calls to global
functions that are completely beyond me. I'm not even sure
they are doing anything now. Can someone throw some light
on them:
Here is a series of calls from VBA, fololowed by some of
the functions:

GrayMenuItem 0, 2
GrayMenuItem 1, 10
GrayMenuItem 1, 11
GrayMenuItem 1, 13
GrayMenuItem 1, 14
GraySubMenuItem 2, 1, 0
GraySubMenuItem 2, 1, 1
GraySubMenuItem 2, 1, 2
ChkMenuItem 3, 1

Here are some of the functions:

Sub GrayMenuItem(intTopLevel As Long, intSubLevel As Long)
On Error Resume Next

Const MF_BYPOSITION = &H400
Const MF_GRAYED = &H1

Dim intSubMenu As Integer
Dim intReturnCode As Integer

If IsZoomed(Forms!frmMain.hWnd) <> 0 Then
intTopLevel = intTopLevel + 1
End If

intSubMenu = GetMenuHandles(intTopLevel)

intReturnCode = EnableMenuItem(intSubMenu,
intSubLevel, MF_GRAYED Or MF_BYPOSITION)

End Sub

Sub UnGrayMenuItem(intTopLevel As Long, intSubLevel As
Long)
On Error Resume Next

Const MF_BYPOSITION = &H400
Const MF_GRAYED = &H1

Dim intSubMenu As Integer
Dim intReturnCode As Integer

If IsZoomed(Forms!frmMain.hWnd) <> 0 Then
intTopLevel = intTopLevel + 1
End If

intSubMenu = GetMenuHandles(intTopLevel)

intReturnCode = EnableMenuItem(intSubMenu,
intSubLevel, Not MF_GRAYED And MF_BYPOSITION)

End Sub

Sub UnGraySubMenuItem(intTopLevel As Long, intSubLevel As
Long, intSubItem As Long)
On Error Resume Next

Const MF_BYPOSITION = &H400
Const MF_GRAYED = &H1

Dim intSubSubMenu As Integer
Dim intReturnCode As Integer

If IsZoomed(Forms!frmMain.hWnd) <> 0 Then
intTopLevel = intTopLevel + 1
End If

intSubSubMenu = GetSubMenuHandles(intTopLevel,
intSubLevel)

intReturnCode = EnableMenuItem(intSubSubMenu,
intSubItem, Not MF_GRAYED And MF_BYPOSITION)

End Sub

Function GetMenuHandles(intTopLevel As Long) As Long

Dim intHwnd As Long
Dim intHwndAccess As Long
Dim intMenuTop As Long

intHwnd = GetActiveWindow()

Do
intHwndAccess = intHwnd
intHwnd = GetParent(intHwnd)
Loop While intHwnd <> 0

intMenuTop = GetMenu(intHwndAccess)

GetMenuHandles = GetSubMenu(intMenuTop, intTopLevel)

End Function
 
D

Dave Cousineau

to me it looks like some person is using API calls to
directly manipulate the menu

the parameters appear to indicate which menu item hes
refering to. top level means , for example, File, Edit,
View, etc.. IE the external, or TopLevel menus

submenu is the commands under the Top Level menu
i would also guess that GrayMenuItem disables a menu item,
ungraymenuitem enables one, etc...

hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top