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 Private Const MF_BYPOSITION = &H400&
Sub SetMenuBitmap(Picture As StdPicture, CheckedPicture As StdPicture, _ ByVal hWnd As Long, ParamArray menuPos() As Variant) Dim hMenu As Long Dim id As Long Dim i As Long Dim chkPicture As StdPicture If CheckedPicture Is Nothing Then Set chkPicture = Picture Else Set chkPicture = CheckedPicture End If hMenu = GetMenu(hWnd) For i = 0 To UBound(menuPos) - 1 hMenu = GetSubMenu(hMenu, menuPos(i)) Next If Picture Is Nothing Then SetMenuItemBitmaps hMenu, menuPos(UBound(menuPos)), MF_BYPOSITION, 0, 0 Else SetMenuItemBitmaps hMenu, menuPos(UBound(menuPos)), MF_BYPOSITION, _ Picture.Handle, chkPicture.Handle End If End Sub |