使用 .net 和 c# 从任务栏中删除应用程序图标 [英] remove application icon from the taskbar using .net with c#

查看:44
本文介绍了使用 .net 和 c# 从任务栏中删除应用程序图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在任务栏上显示图标,我就是这样做的.

I am trying to show icon on the taskbar, well i did this in this way.

ResourceManager resManager = new ResourceManager("TestAgent.Properties.Resources", GetType().Module.Assembly);
                notifyicon.Icon = (Icon)resManager.GetObject("TestAgent");
                notifyicon.Visible = true;
                notifyicon.Text = "Test Agent";
                this.Hide();
                this.ShowInTaskbar = false;
                this.SetVisibleCore(false); 

另一方面,当尝试以这种方式从任务栏中删除图标时.

On other side when try remove icon from the taskbar doing in this way.

notifyicon.Visible = false;
            notifyicon = null;
            rulehandler = null;

我成功地做到了这一点,但问题是当尝试从任务栏中删除图标时,它成功地从任务栏中删除了图标但没有隐藏图标,当将鼠标悬停在它删除的图标上时.

I did this successfully but the problem is when try to remove icon from the taskbar it remove icon successfully from the taskbar but not hide the icon, When hover the mouse on the icon it removes.

有没有办法在没有鼠标悬停的情况下删除图标?我正在使用 c# 以 windows 形式执行此操作

Is there anyway to remove icon without mouse hover? I am doing this in windows form with c#

推荐答案

Simply Dispose it.

Simply Dispose it.

在 Windows 窗体中,您可以订阅全局事件 ApplicationExit ...

In a Windows Form you can subscribe to the global event ApplicationExit ...

Application.ApplicationExit += new EventHandler(this.OnApplicationExit);

private void OnApplicationExit(object sender, EventArgs e) {
     notifyicon.Dispose();
}

这篇关于使用 .net 和 c# 从任务栏中删除应用程序图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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