views:

132

answers:

2

I needed to update the system tray icon's text value, of my application, whenever a user hovers over it. I noticed that no such event exists for system tray icons. Is it possible to create a hover event for a system tray icon and if so how can I go about accomplishing it?

+5  A: 

How about hooking into NotifyIcon.MouseMove?

As a basic example, this seems to work (with a NotifyIcon on a Form):

    public Form1() {
        InitializeComponent();
        notifyIcon1.MouseMove += delegate
        {
            notifyIcon1.Text = DateTime.Now.TimeOfDay.ToString();
        };
        notifyIcon1.Icon = SystemIcons.Hand;
        notifyIcon1.Visible = true;            
    }
Marc Gravell
Hey Marc - good to see they made you a mod!
Dead account
Indeed, but I was going for "rocker" ;-p
Marc Gravell
A: 

In WPF, UI Elements have a ToolTipOpening/ToolTipClosing event. You should update the tooltip text in the opening. I don't know if system tray icons have such behavior, but i guess there is something similar.

rockeye