托盘栏中打开多个图标 [英] Multiple icons open in tray bar

查看:65
本文介绍了托盘栏中打开多个图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows应用程序,当我运行该应用程序时,托盘栏上会出现多个图标:

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

推荐答案

这是我关闭系统任务栏图标以在我刚才编写的程序中显示完整应用程序的方式:

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

注意:这很适合后面代码中的事件处理程序,因此this.Show()和this.Activate()

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

这篇关于托盘栏中打开多个图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆