How to associate icons with menu items

  • Thread starter Thread starter Joyce Liu
  • Start date Start date
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
 
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
 
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
 
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'?
 
Back
Top