Tag: trayicon

更改系统托盘图标图像

我在.Net中构建了一个托盘应用程序,工作正常。 但是,用户希望在某些条件下在运行时更改“托盘图标”图像。 为了简单起见,让我们说,有些东西不起作用 – 托盘图标应该显示红色图像; 如果一切都很好,它应该显示绿色。 我不知道如何在.Net中实现这一目标。 请提供一些意见。 谢谢 我为Tray构建了CustomApplicationContent。 下面的一些片段: Program.cs中 [STAThread] static void Main() { if (!SingleInstance.Start()) { return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { var applicationContext = new CustomApplicationContext(); Application.Run(applicationContext); } catch (Exception ex) { MessageBox.Show(ex.Message, “Program Terminated Unexpectedly”, MessageBoxButtons.OK, MessageBoxIcon.Error); } SingleInstance.Stop(); } CustomApplicationContext.cs public class CustomApplicationContext : ApplicationContext { private System.ComponentModel.IContainer […]

以编程方式刷新系统托盘图标

我有一个有系统托盘图标的应用程序。 在卸载时,如果它正在运行,我将终止该进程。 因此,由于没有优雅地停止应用程序,图标仍保留在系统托盘中,只有当我们将鼠标hover在系统托盘上时才会删除。 我编写了一个代码,可以沿托盘运行光标并将光标放回原始位置。 这就是我所做的: [DllImport(“user32.dll”)] static extern IntPtr FindWindow(string className, string windowName); [DllImport(“user32.dll”)] static extern IntPtr FindWindowEx(IntPtr parent, IntPtr child, string className, string windowName); [DllImport(“user32.dll”)] static extern bool GetWindowRect(HandleRef handle, out RECT rct); [StructLayout(LayoutKind.Sequential)] struct RECT { public int Left; public int Top; public int Right; public int Bottom; } void RefreshTray() { IntPtr […]

C#trayicon使用wpf

我是C#编程的新手,虽然我已经在unity3D中用C#编写了几年。 我正在尝试制作一个WPF托盘图标,我在网上找到的所有资源告诉我使用 System.Windows.Forms 但是。对于我来说,System.Windows中没有.Forms,我不知道为什么不这样做。 谁能帮我这个?