I cannot find this feature at all. There is no bitmap property for menu
items nor is there an imagelist property for the menu itself...
How do I put images to the left of menu items?
Thanks,
Lynn
Hello Lynn,
You'll have to set the MenuItems OwnerDraw property to true, and then write
some code on the DrawItem and MeasureItem events to draw the menu items by
yourself.
Unfortunately (please take note .NET guys!) there is no "Tag" property on
the MenuItem class as to redirect all menu items events to the same handlers
and use the Tag as an index to an ImageList. So I guess you'll have to:
* Write a specific draw event for each item
-or-
* Somehow use the sender index (if rational) to address the image to draw
-or-
* Create your own class inheriting from MenuItem in a sepparate dll that
Adds ImageList and ImageIndex property and do the drawing.
To draw the item, you'll have to use the passed DrawItemEventArgs in the
DrawItem handler, that has a graphics object to use to draw plus some handy
methods as to fill the background with the proper colors, get the text color,
etc.
As mentioned above, you will also need to write a handler for MeasureItem as
to tell to Windows to add the extra space the bitmaps will take.
Hope it helps.
Libertadrian
"Give me freedom or give me death"
> I cannot find this feature at all. There is no bitmap property for menu
> items nor is there an imagelist property for the menu itself...
[quoted text clipped - 4 lines]
>
> Lynn
Lynn Morrison - 30 Sep 2004 02:30 GMT
> Unfortunately (please take note .NET guys!) there is no "Tag" property on
> the MenuItem class as to redirect all menu items events to the same handlers
[quoted text clipped - 18 lines]
> As mentioned above, you will also need to write a handler for MeasureItem as
> to tell to Windows to add the extra space the bitmaps will take.
Wow, what a kludge. As images on menus is a common occurence, I find it
hard to believe that the .NET people did not incorporate this functionality
into the menu components when designing it in the first place.
Thanks for the help. I may see if it is difficult to perhaps derive from the
menu to include that feature. I think it would be widely accepted by the
community, if I am not mistaken. My goal is to have an imagelist attached to
the menu and then just set imageindex to the desired image for each of the
menu items...
Thanks again,
Lynn
Libertadrian - 30 Sep 2004 03:59 GMT
There is another method using IExtenderProvider. It's for C#, I didn't try
it, but you should be able to adapt it to C++.
http://www.thecodeproject.com/cs/menu/menuimage.asp
> > Unfortunately (please take note .NET guys!) there is no "Tag" property on
> > the MenuItem class as to redirect all menu items events to the same
[quoted text clipped - 36 lines]
>
> Lynn
Wim Morrison - 30 Sep 2004 07:55 GMT
> There is another method using IExtenderProvider. It's for C#, I didn't try
> it, but you should be able to adapt it to C++.
[quoted text clipped - 41 lines]
> >
> > Lynn
There is an enormous kludge that works easily. Take the image, and
shrink it to 12x12. Then use it as the 'checkmark' image for the menu
item. If you set it to the 'no check' item and do not checkmark the item
then you only need 1 12x12 bitmap.

Signature
Wim Morrison
abuse@html.com.au