如何用SetMenuItemInfo实现ModifyMenu的功能
'SetMenuItemInfo用法Private Const MFT_RADIOCHECK = &H200&Private Const MIIM_TYPE = &H10Private Const MIIM_SUBMENU = &H4Private 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 LongEnd TypePrivate Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As LongPrivate Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Boolean, lpmii As MENUITEMINFO) As LongPrivate Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal uItem As Long, ByVal fByPosition As Long, lpmii As MENUITEMINFO) As LongPrivate Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As LongPrivate 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, MIIEnd SubPrivate Sub mnuFileMenuItem_Click() 'if checked then uncheck 'if unchecked then check mnuFileMenuItem.Checked = Not (mnuFileMenuItem.Checked)End Sub
标签:SetMenuItemInfo,ModifyMenu