NotifyIcon handler not receiving mouse events 
Author Message
 NotifyIcon handler not receiving mouse events

I'm having a problem with a simple winform application and I'm about to pull
all my hair out.  I've placed the notifyicon control on the form and have no
problems getting it to display tooltip text or a context menu.  The context
menu and the tooltip text works so at least on some level I know the system
tray icon is receiving mouse events.  However, none of the mouse_* event
handlers in my code are called when a user clicks on the icon in the system

This is the winform designer generated code for capturing the events:

this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);
this.notifyIcon1.MouseUp += new

Here are my various event handlers:

private void notifyIcon1_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e) {


private void notifyIcon1_Click(object sender, System.EventArgs e) {

protected void Show_Test(Object sender, System.EventArgs e) {
    MessageBox.Show("Menu item selected!");


Here are my definitions + initialization code:

private System.Windows.Forms.NotifyIcon notifyIcon1;
private ContextMenu TrayMenu = new ContextMenu();

notifyIcon1 = new NotifyIcon();
notifyIcon1.Text = "This is my tooltip text";
notifyIcon1.Visible = true;
notifyIcon1.Icon = new Icon(GetType(),"Icon1.ico");
TrayMenu.MenuItems.Add(0, new MenuItem("Test", new
notifyIcon1.ContextMenu = TrayMenu;

I'm fairly certain I'm just missing something obvious -- could someone point
it out?


Shelby Cain

Wed, 02 Feb 2005 03:53:37 GMT  
 NotifyIcon handler not receiving mouse events
The obvious thing I overlooked:

s/notifyIcon1 = new NotifyIcon();//

I was creating a new instance because the example code assumed you didn't
use the form designer to place the control on the form.  Of course, the form
designer took care of setting all the event handlers for the original
control -- and properly discarded them when I changed the reference.

Wed, 02 Feb 2005 05:28:34 GMT  
 [ 2 post ] 

 Relevant Pages 

1. ImageButton Click Event Handler Not Getting Fired, why not

2. Why are change notifications received before mouse events?

3. Mouse Event Handler, under DOS: HELP!!!

4. Mouse Event Handler

5. Again...writing mouse event handler

6. Trouble writing my own Mouse Event Handler.

7. Writing Mouse Event Handler

8. How to add a mouse handler that handles double click events

9. Mouse Event Handlers

10. CListCtrl left mouse click event handler

11. Why Mouse Mouse event with every Click event

12. Mouse messages not received iin control


Powered by phpBB® Forum Software