adding images to a menu

I need to be able to add images to a menu like the favorites list in IE. Does anyone have some sample code to do this?
Who is Participating?
Erick37Connect With a Mentor Commented:
'Menu pictures should be 13x13 pixel 16 color bitmaps.  The following code inserts 2 bitmaps into a menu.  The bitmaps were loaded into an ImageList at design time.

Option Explicit

'Download Here:

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 Const MF_BITMAP = &H4&
'This is the position of your popup menu
'The first top level menu index is 0
Private Const MNUPOS = 0 '< change this to match your top menu index

Private Sub Form_Load()
    Dim hMenu As Long
    Dim hSubMenu As Long
    Dim hID As Long
    'Get the menuhandle of your app
    hMenu = GetMenu(hwnd)
    'Get the handle of the menu in list
    hSubMenu = GetSubMenu(hMenu, MNUPOS)
    'Get the menuId of the first entry
    hID = GetMenuItemID(hSubMenu, 0)
    'Add the bitmap
    'You can add two bitmaps to a menuentry
    'One for the checked and one for the unchecked state.
    SetMenuItemBitmaps hMenu&, hID, MF_BITMAP, _
        ImageList1.ListImages(1).Picture, _
    hID& = GetMenuItemID(hSubMenu&, 1)
    'Add a bitmap to the second menu item
    SetMenuItemBitmaps hMenu, hID, MF_BITMAP, _
        ImageList1.ListImages(2).Picture, _
    'and so on...
End Sub
masterpoeAuthor Commented:
manojamin posting another one for your points. Thanks!
All Courses

From novice to tech pro — start learning today.