您的位置首页生活百科

如何用setmenuiteminfo实现modifymenu的功能

如何用setmenuiteminfo实现modifymenu的功能

的有关信息介绍如下:

如何用setmenuiteminfo实现modifymenu的功能

SetMenuItemInfo用法 Private Const MFT_RADIOCHECK = &H200& Private Const MIIM_TYPE = &H10 Private Const MIIM_SUBMENU = &H4 Private Type MENUITEMINFOcbSize As LongfMask As LongfType As LongfState As LongwID As LonghSubMenu As LonghbmpChecked As LonghbmpUnchecked As LongdwItemData As LongdwTypeData As Stringcch 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 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 Long Private Sub Form_Load()'URL:'E-Mail: KPDTeam@allapi.netDim hMenu As Long, hSubMenu As Long, MII As MENUITEMINFO'get the handle of the current menuhMenu = GetMenu(Me.hwnd)'get the handle of the first submenuhSubMenu = GetSubMenu(hMenu, 0)'initialize the structureMII.cbSize = Len(MII)MII.fMask = MIIM_SUBMENU'retrieve information about the menu itemGetMenuItemInfo hSubMenu, 0, True, MIIIf MII.hSubMenu <> 0 ThenMsgBox "The specified menu item has a submenu."ElseMsgBox "The specified menu item doesn't have a submenu."End If'display checked menu items using a radio-button mark instead of a check markMII.fMask = MIIM_TYPEMII.fType = MFT_RADIOCHECKMII.dwTypeData = mnuFileMenuItem.CaptionSetMenuItemInfo hSubMenu, 0, True, MII End Sub Private Sub mnuFileMenuItem_Click()'if checked then uncheck'if unchecked then checkmnuFileMenuItem.Checked = Not (mnuFileMenuItem.Checked) End Sub