NotifyIcon Click Problem
-
NotifyIcon Click Problem I setup my NotifyIcon named "sysTray" as
class MainForm : Form { void setUpTrayIcon() { sysTray.Icon = Icon.ExtractAssociatedIcon("App.ico"); this.Shown += delegate(object o, EventArgs ev) { sysTray.Visible = true; }; sysTray.Click += new EventHandler(doSysClick); MenuItem[] itm = {new MenuItem("Prev", new EventHandler(doPrev)), new MenuItem("Next",new EventHandler(doNext)), new MenuItem("Stop", new EventHandler(doStop))}; this.trayMenu = new ContextMenu(itm); sysTray.ContextMenu = this.trayMenu; } }
The Icon showsup correctly in System Tray Area. When I Right Click on it the Menu also shows up. But once the Menu is Poped Up then It does not matter if I click on the Menu or My App's Tray Icon the sysTray.Click Item still gets Fired and my EventHandler, doSysClick is called. What I expect is that Only when I click on the App Icon in the System Tray should my doSysClick method be called. If My System Tray Menu is Visible then if I click anywhere outside it, then it should just hide itself (that is the usual behaviour). So what am I missing? Thanks... -
NotifyIcon Click Problem I setup my NotifyIcon named "sysTray" as
class MainForm : Form { void setUpTrayIcon() { sysTray.Icon = Icon.ExtractAssociatedIcon("App.ico"); this.Shown += delegate(object o, EventArgs ev) { sysTray.Visible = true; }; sysTray.Click += new EventHandler(doSysClick); MenuItem[] itm = {new MenuItem("Prev", new EventHandler(doPrev)), new MenuItem("Next",new EventHandler(doNext)), new MenuItem("Stop", new EventHandler(doStop))}; this.trayMenu = new ContextMenu(itm); sysTray.ContextMenu = this.trayMenu; } }
The Icon showsup correctly in System Tray Area. When I Right Click on it the Menu also shows up. But once the Menu is Poped Up then It does not matter if I click on the Menu or My App's Tray Icon the sysTray.Click Item still gets Fired and my EventHandler, doSysClick is called. What I expect is that Only when I click on the App Icon in the System Tray should my doSysClick method be called. If My System Tray Menu is Visible then if I click anywhere outside it, then it should just hide itself (that is the usual behaviour). So what am I missing? Thanks...