0
在将主(第一个)PopUp菜单项Visible属性设置为False后,图标在PopUp菜单中消失,但当Visible属性切换回Enable时,图标消失,为什么?图标在PopUp菜单中消失VB6
Option Explicit
Private Const MF_BITMAP = &H4&
Private Const MF_BYPOSITION As Long = &H400& '&H404&
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long
Public Sub SetPopUpMenuIcons(objFRM As Form)
On Error Resume Next
Dim lgRet As Long
Dim lgMnu As Long
Dim lgSubMnu As Long
lgMnu = GetMenu(objFRM.hwnd)
lgSubMnu = GetSubMenu(lgMnu, 0)
With objFRM
lgRet = SetMenuItemBitmaps(lgSubMnu, 0, MF_BYPOSITION, .imgMnu(0).Picture, 0)
lgRet = SetMenuItemBitmaps(lgSubMnu, 1, MF_BYPOSITION, .imgMnu(1).Picture, 0)
lgRet = SetMenuItemBitmaps(lgSubMnu, 2, MF_BYPOSITION, .imgMnu(2).Picture, 0)
lgRet = SetMenuItemBitmaps(lgSubMnu, 3, MF_BYPOSITION, .imgMnu(3).Picture, 0)
lgRet = SetMenuItemBitmaps(lgSubMnu, 4, MF_BYPOSITION, .imgMnu(4).Picture, 0)
End With
Exit Sub
End Sub