Multiple icons open in tray bar

2019-07-24 09:08发布

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);
}

1条回答
戒情不戒烟
2楼-- · 2019-07-24 10:00

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();
查看更多
登录 后发表回答