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