• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 158
  • Last Modified:

Using bitmaps in menu items

How do you use the API in order to attach bitmap images to items in a drop down menu?
0
rossom
Asked:
rossom
  • 3
  • 2
1 Solution
 
jjmartinCommented:
Here is some code that will add the bitmaps to your menu.

 Dim i%
  Dim hMenu, hSubMenu, menuID, x
  hMenu = GetMenu(hwnd)
  hSubMenu = GetSubMenu(hMenu, 0) '1 for "Other" menu etcetera
  For i = 1 To 4
    menuID = GetMenuItemID(hSubMenu, i - 1)
    x = SetMenuItemBitmaps(hMenu, menuID, &H4, img.ListImages(i).Picture, img.ListImages(i).Picture)
  Next
  menuID = GetMenuItemID(hSubMenu, 5)
  x = SetMenuItemBitmaps(hMenu, menuID, 0, img.ListImages(5).Picture, 0&)
0
 
twardCommented:
This doesn't seem to work?
0
 
jjmartinCommented:
It works on my PC running VB5, where is the code failing on you?
0
 
twardCommented:
 x = SetMenuItemBitmaps(hMenu, menuID, &H4, img.ListImages(i).Picture, img.ListImages(i).Picture)

seems to be returning 0?

I cut your code out to see if it would work so it is exactly as above!

0
 
twardCommented:
Sorry,

  It does work here also, I had ICONS in the ImageList instead of Bitmaps.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now