如何尽量减少WinForms应用程序的通知区域?应用程序、区域、通知、WinForms

2023-09-04 22:32:05 作者:嘻哈1号店

我希望尽量减少一个C#WinForms应用程序到系统托盘。我试过这样的:

I want to minimize a C# WinForms app to system tray. I've tried this:

Having该应用程序最小化到系统托盘按钮被点击时?。我第一次最小化,这是无处可在屏幕上找到 - 任务栏/任务栏上方/托盘

Having the application minimize to the system tray when button is clicked?. The first time I minimize it, it's nowhere to be found on the screen - taskbar/above taskbar/tray.

如果我打的alt标签,我可以看到我的应用程序有;如果我按alt标签到它,并再次将它最小化,它显示在任务栏上面的:

If i hit alt tab, I can see my app there; if I alt tab into it and minimize it again, it shows up above the taskbar:

我是什么做错了吗?

推荐答案

最小化怎么样隐藏形式的选项时,则显示出,一旦你点击托盘图标?

What about the option of hiding the form when minimized then showing once you click on the tray icon?

在窗体调整大小事件,做检查那里隐藏窗体

In the form resize event, do the check there and hide the form

   private void Form_Resize(object sender, EventArgs e)
    {
        if (WindowState == FormWindowState.Minimized)
        {
            this.Hide();
        }
    }

然后在任务栏的图标上单击时只是恢复它。

Then when clicking on the taskbar icon just restore it.

    private void notifyIcon_Click(object sender, EventArgs e)
    {
        this.Show();
        this.WindowState = FormWindowState.Normal;
    }