隐藏到托盘(C#)

        private void Form1_Resize(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)//最小化到系统托盘
            {
                notifyIcon1.Visible = true;//显示托盘图标
                this.Hide();//隐藏窗口
            }
        }

        private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.Show();
                WindowState = FormWindowState.Normal;
                this.Focus();
            }
        }

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

        private void label_close_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;//使关闭时窗口向右下角缩小的效果
        }

 

posted @ 2015-12-03 12:08  margin_gu  阅读(819)  评论(0)    收藏  举报