.net - 最小化时如何将.net应用程序放在系统托盘中?

标签 .net system system-tray

任何人都可以建议vb.net/c#代码的良好代码示例来在最小化时将其放入系统托盘。

最佳答案

将NotifyIcon控件添加到您的窗体,然后使用以下代码:

    private void frm_main_Resize(object sender, EventArgs e)
    {
        if (this.WindowState == FormWindowState.Minimized)
        {
           this.ShowInTaskbar = false;
           this.Hide();
           notifyIcon1.Visible = true;
        }
    }

    private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
    {
        this.Show();
        this.WindowState = FormWindowState.Normal;
        this.ShowInTaskbar = true;
        notifyIcon1.Visible = false;
    }

您可能不需要设置ShowInTaskbar属性。

关于.net - 最小化时如何将.net应用程序放在系统托盘中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76079/

相关文章:

c# - HORN 的实际应用是什么?

networking - UDP 服务器负载平衡

python - 如何为应用程序制作自定义托盘图标?

c++ - 自定义系统托盘通知 Qt

C# FatClient Facebook 身份验证失败 : Return URI contains no token

c# - 如何为动态加载的 native dll 调整 %PATH%?

.net - F# 删除函数处理程序

android - 如何从另一个应用程序启动应用程序?

string - 从 Bash 脚本检测操作系统并通知用户

Java 桌面应用 : How to maximize tray application when hotkey pressed?