G.S Bhangal
G.S Bhangal

Reputation: 3280

Multiple icons open in tray bar

I am working on a Windows application, and when I run this application, there are multiple icons appearing on the tray bar:

and when I mouse-over these icons, they disappear.

Does anybody have any idea why this is happening?

protected override void OnClosed(EventArgs e)
{
    try
    {
        notifyIcon1.Visible = false;
        notifyIcon1.Icon.Dispose();
        notifyIcon1.Dispose();
    }
    catch(Exception ex)
    {
    }
    base.OnClosed(e);
    Environment.Exit(0);
}

Upvotes: 3

Views: 2570

Answers (1)

kformeck
kformeck

Reputation: 1923

Here is how I close my system tray icon to bring up the full application in a program I wrote a while back:

NOTE: this fits well in an event handler in the code behind, hence this.Show() and this.Activate()

            NotifyIcon sysTrayIcon = sender as NotifyIcon;
            sysTrayIcon.Visible = false;
            this.WindowState = WindowState.Normal;
            this.Show();
            this.Activate();

Upvotes: 1

Related Questions