VistaMenu with a NotifyIcon

Hey,

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:

        private static VistaMenu _vistaMenu = new VistaMenu();        private static void SetImage(this MenuItem menuItem, Image image)        {            _vistaMenu.SetImage(menuItem, image);        }
menuItem.SetImage(bar);

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?

Thanks!

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:

//EndInit() is called by the designer on forms, but since this//is an ApplicationContext you need to call it manually((System.ComponentModel.ISupportInitialize)(vistaMenu)).EndInit();

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.