How do you add BMPs to a PopupMenu? I tried doing the same thing you do for standard menus and this does not work. Any ideas?
Code:
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 GetMenuItemID 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 Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Boolean, IpMenuItemInfo As MENUITEMINFO) As Boolean
Private Type MENUITEMINFO
cbSize As Long
fMask 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 Long
End Type
Private Const MIIM_ID = &H2
Private Const MIIM_TYPE = &H10
Private Const MFT_STRING = &H0&
Private Const MF_BITMAP = &H0&
Dim hMenu As Long, hSubMenu As Long, hID As Long
'Get the Menuhandle of the form
hMenu = GetMenu(frmMain.hwnd)
'Get the handle of the PopupMenu submenu
hSubMenu = GetSubMenu(hMenu, 0)
hID = GetMenuItemID(hSubMenu, 0)
SetMenuItemBitmaps hMenu, hID, MF_BITMAP, imgMenuItem(0).Picture, imgMenuItem(0).Picture
hID = GetMenuItemID(hSubMenu, 1)
SetMenuItemBitmaps hMenu, hID, MF_BITMAP, imgMenuItem(0).Picture, imgMenuItem(0).Picture
hID = GetMenuItemID(hSubMenu, 2)
SetMenuItemBitmaps hMenu, hID, MF_BITMAP, imgMenuItem(1).Picture, imgMenuItem(1).Picture Thanks,
Tim