Solved

Using bitmaps in menu items

Posted on 1998-07-22
5
147 Views
Last Modified: 2010-05-03
How do you use the API in order to attach bitmap images to items in a drop down menu?
0
Comment
Question by:rossom
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
jjmartin earned 50 total points
ID: 1466411
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
 
LVL 7

Expert Comment

by:tward
ID: 1466412
This doesn't seem to work?
0
 
LVL 3

Expert Comment

by:jjmartin
ID: 1466413
It works on my PC running VB5, where is the code failing on you?
0
 
LVL 7

Expert Comment

by:tward
ID: 1466414
 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
 
LVL 7

Expert Comment

by:tward
ID: 1466415
Sorry,

  It does work here also, I had ICONS in the ImageList instead of Bitmaps.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now