Private Const MFT_RADIOCHECK = &H200&
Private Const MIIM_TYPE = &H10
Private Const MIIM_SUBMENU = &H4
Private Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Boolean, lpmii As MENUITEMINFO) As Long
Private Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal uItem As Long, ByVal fByPosition As Long, lpmii As MENUITEMINFO) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Sub Form_Load()
'URL: http://www.allapi.net
'E-Mail: KPDTeam@allapi.net
Dim hMenu As Long, hSubMenu As Long, MII As MENUITEMINFO
'get the handle of the current menu
hMenu = GetMenu(Me.hwnd)
'get the handle of the first submenu
hSubMenu = GetSubMenu(hMenu, 0)
'initialize the structure
MII.cbSize = Len(MII)
MII.fMask = MIIM_SUBMENU
'retrieve information about the menu item
GetMenuItemInfo hSubMenu, 0, True, MII
If MII.hSubMenu <> 0 Then
MsgBox "The specified menu item has a submenu."
Else
MsgBox "The specified menu item doesn't have a submenu."
End If
'display checked menu items using a radio-button mark instead of a check mark
MII.fMask = MIIM_TYPE
MII.fType = MFT_RADIOCHECK
MII.dwTypeData = mnuFileMenuItem.Caption
SetMenuItemInfo hSubMenu, 0, True, MII
End Sub
Private Sub mnuFileMenuItem_Click()
'if checked then uncheck
'if unchecked then check
mnuFileMenuItem.Checked = Not (mnuFileMenuItem.Checked)
End Sub