How to associate icons with menu items

J

Joyce Liu

Does anyone know a quick and easy way to place icon images in menu items of
a MainMenu control? This is usually an effortless task for other controls
using their ImageList properties, which is not available for MainMenu. The
only way I can find is to set the menu item's OwnerDraw property to true and
write code to handle the MeasureItem and DrawItem events.

TIA for any input.

Joyce Liu
 
H

Herfried K. Wagner

Hello,

Joyce Liu said:
Does anyone know a quick and easy way to place
icon images in menu items of a MainMenu control?
This is usually an effortless task for other controls
using their ImageList properties, which is not available
for MainMenu. The only way I can find is to set the
menu item's OwnerDraw property to true and
write code to handle the MeasureItem and DrawItem events.

Outlook Express style:

http://www.aisto.com/roeder/dotnet/
-> "CommandBar for .NET"

VS .NET style menu:

http://www.dotnetmagic.com/

VS .NET style toolbar:

http://www.codeproject.com/cs/menu/vsnettoolbar.asp

Regards,
Herfried K. Wagner
 
J

Jerry Ham

If you do choose to owner draw them (which works), you are in for a surprise
if you try to owner draw a popup menu from a tray icon. The owner draw of
the icon won't seem to work there (at least in 1.0 of the framework). I had
it working fine like you mention with the MeasureItem, DrawItem and all from
the mainmenu. But then, do the same thing with a popup from a trayicon and I
could never make it work...

Jerry
 
S

Slonjo

I am trying the context menu from the NotifyIcon also. No luck. The
menu background draws and any non-IconMenuItems I have in it but the
custom menu item's 'OnDrawItem' never fires.

The .NET context menu concept differs from the old 'popup' menu in
that you now have to assign the menu to a control to show it. Why did
they have to go and do that instead of just letting us assign a screen
position for it to 'appear'?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top