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?
masterpoeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

manojaminCommented:
0
Erick37Commented:
'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: http://www.vbtutor.com/downloads/bitmapmenu.zip

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, _
        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, _
        ImageList1.ListImages(2).Picture
    'and so on...
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
masterpoeAuthor Commented:
manojamin posting another one for your points. Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.