码迷,mamicode.com
首页 > Windows程序 > 详细

Winform 窗体最小化隐藏在桌面右下角:转

时间:2016-07-21 21:50:50      阅读:413      评论:0      收藏:0      [点我收藏+]

标签:

ICO文件要放到 bin\Debug 下 

 

1、给主窗体添加 NotifyIcon 控件

 

2、窗体加载事件里

 

        private void MainF_Load(object sender, EventArgs e)
        {
            this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
            notifyIcon1.Icon = new Icon("JC.ico");
            notifyIcon1.Visible = false;
            notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);
            this.SizeChanged += new System.EventHandler(this.MainF_SizeChanged);
        }

 

3、窗体的SizeChanged事件

 

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

 

4、窗体加载事件里的notifyIcon1_Click方法

 

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

Winform 窗体最小化隐藏在桌面右下角:转

标签:

原文地址:http://www.cnblogs.com/candyzhmm/p/5692926.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!