Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. NotifyIcon Click Problem

NotifyIcon Click Problem

Scheduled Pinned Locked Moved C#
helpquestionworkspace
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sukhjinder_K
    wrote on last edited by
    #1

    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...

    D 1 Reply Last reply
    0
    • S Sukhjinder_K

      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...

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      Use the MouseClick, MouseDoubleClick etc... events instead of the general click event.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups