如何尽量减少WinForms应用程序的通知区域? [英] How do I minimize a WinForms application to the notification area?

查看:154
本文介绍了如何尽量减少WinForms应用程序的通知区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

<一个href="http://stackoverflow.com/questions/1297028/having-the-application-minimize-to-the-system-tray-when-button-is-clicked">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;
    }

这篇关于如何尽量减少WinForms应用程序的通知区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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