簡體   English   中英

使用.net和C#從任務欄中刪除應用程序圖標

[英]remove application icon from the taskbar using .net with c#

我正在嘗試在任務欄上顯示圖標,好吧,我是這樣做的。

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

另一方面,嘗試以這種方式從任務欄中刪除圖標。

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

我成功完成了此操作,但問題是當嘗試從任務欄刪除圖標時,它成功從任務欄刪除了圖標,但沒有隱藏圖標,將鼠標懸停在圖標上時,它刪除了。

反正有沒有鼠標懸停刪除圖標? 我正在用C#在Windows窗體中執行此操作

簡單地處理它。

在Windows窗體中,您可以訂閱全局事件ApplicationExit ...

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

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

只需編寫notifyIcon.Visible = false; (在Icon中用大寫字母I表示),然后再關閉窗口,這樣您就可以開始了。 就如此容易。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM