How to place an icon next to a menu item
Hello. I'm sorry for asking this but for the last hour I've been looking for a simple answer to my question and can't find one.
Anyways, I am creating a menu on a VB6 form using the menu editor. (I know there's other controls out there that look way better - but I'm a little leary about using an .ocx I didn't create in my program - and I actually don't think the VB6 menu looks that bad).
How do I place an icon next to my menu item? I am aware of the "SetMenuItemBitmaps" API but this apparently only places a bitmap next to the menu item - whereas I would like to place the .ico file next to it. This is relatively easy to do right??
Re: How to place an icon next to a menu item
IIRC you can only put bitmaps next to menu items.
Re: How to place an icon next to a menu item
y don't you use toolbars or coolbar instead?
Re: How to place an icon next to a menu item
I'd love to use a coolbar or toolbar for the menu - but it appears to be a lot of work to create a menu that way (or is it?) It's just frustrating because I'm happy with the look of the VB6 menu - which is very easy to create - and all I want to do now is place a little 'ol icon next to the menu item - it must be possible right? I tried using the bitmap but the result looked very poor.
Does anyone know how to do this??
Re: How to place an icon next to a menu item
I hope this helps you....
Re: How to place an icon next to a menu item
Thanks for the link dee-u. However, as great as that program looks, I'm really just looking for a quick answer. Apparently this must be harder to do than I thought :sick: Oh well, I guess I'll just have to live without it (sigh).
Re: How to place an icon next to a menu item
It maybe a good investment to learn how did they do it, why dont you try? ;)
Re: How to place an icon next to a menu item
For a basic image to be added to a menu you can use the SetMenuItemBitmaps API. To get the handle
of the menus you will need to use GetMenu and GetSubMenu APIs also. If you dont have the API Viewer and
API Guide then you will find more info on them in there.
Re: How to place an icon next to a menu item
I already tried using those APIs - the problem was the bitmap looked terrible - perhaps I was using an incorrect size for the bitmap file? Can you enlighten me on what size the bitmap file needs to be? Thanks...
Re: How to place an icon next to a menu item
Re: How to place an icon next to a menu item
It needs to be 16 x 16. The issue with this API method is that the selection covers the image causing it to
invert and look terrible. You could subclass the menu and do some owner drawing for the cleanest and trickest
look but its allot of work :(
1 Attachment(s)
Re: How to place an icon next to a menu item
Nice link Hack but it contains the same highlighting issue :(
The only real solution is Owner Drawn menus. The GDI API calls are the ones that you would be interested in.
Re: How to place an icon next to a menu item
Yeah that is exactly what I want! - is it that hard to do? I'd be willing to try if I had some code to review. I know how to get the handle of the menu item, so I wouldn't think it be would too difficult beyond that :ehh: ??
Also, using this approach can you use the icon file instead of a bitmap??
Re: How to place an icon next to a menu item
Here are a number of potential examples.
Re: How to place an icon next to a menu item
Thanks a lot - I'll try it out and let you know whether or not I get it to work...
Re: How to place an icon next to a menu item
It requires subclassing the menu and measuring and drawing everything on themenu. Text, the selection,
the 3d box, inverting the color of the text when its selected, etc. So no its not hard at all. :p
If I get some time I can whip up a demo for you, but I nned to finish something first.
Re: How to place an icon next to a menu item
Thanks to Hack's link I found some code which I believe already does all that - so don't trouble yourself with putting together a demo for now. I'll try it out later today and if it doesn't work then I may take you up on your offer (as the menus in your screenshot are exactly what I'm trying to achieve...)
Re: How to place an icon next to a menu item
Ok, those menus are duplicating the Office 2000 style menus ;)
Just let me know if you need any more help :thumb: