Downloads  |  Buy

VistaMenu with a NotifyIcon

VistaMenu with a NotifyIcon

Postby a2h » April 13th, 2011, 10:58 pm


I just tried to port over a ContextMenuStrip for a NotifyIcon I have in my app to using a plain ContextMenu with VistaMenu. The NotifyIcon isn't initialised on a form, in fact, my app doesn't show any forms until it needs to. I just directly wrote "NotifyIcon foo = new NotifyIcon()" in a class of mine. I'm trying to use the icon setting like so:

[code] private static VistaMenu _vistaMenu = new VistaMenu();
private static void SetImage(this MenuItem menuItem, Image image)
_vistaMenu.SetImage(menuItem, image);


While my menu appears to work fine, the icons don't get set.

I put breakpoints in VistaMenu.cs, and noticed that "formHasBeenIntialized" was false when I was trying to set the icons on my menu items.

Do I need to be more specific, or is there a solution?

Posts: 2
Joined: April 13th, 2011, 10:44 pm

Re: VistaMenu with a NotifyIcon

Postby Sam » April 14th, 2011, 12:45 am

Did you look at the Notify Icon demo in the VistaMenu zip file? Look inside the "DemoNI" folder. My guess is you're missing this:

[code:18vpk90w]//EndInit() is called by the designer on forms, but since this
//is an ApplicationContext you need to call it manually
User avatar
Posts: 3126
Joined: March 8th, 2010, 3:01 am
Location: New Hampshire

Re: VistaMenu with a NotifyIcon

Postby a2h » April 14th, 2011, 7:41 am

Thanks for that. Though, now I seem to get an exception {"Key cannot be null.\r\nParameter name: key"}, unless I make sure that the menu item has already been added. Bit annoying, but eh, unavoidable..?

Now that that's out of the way, I've got {"Unable to cast object of type '---.SectionedContextMenu' to type 'System.Windows.Forms.MenuItem'."}. SectionedContextMenu is a class I wrote, which inherits from ContextMenu. I notice on VistaMenu.cs:179 that there's a check for whether the parent of the menu item is a ContextMenu or not with typeof... hm.
Posts: 2
Joined: April 13th, 2011, 10:44 pm

Return to Open Source Support