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
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