Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • 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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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