日期:2014-05-17  浏览次数:20836 次

winform最小化后隐藏到右下角,单击或双击后恢复
我知道这个方法怎么写,我不知道什么时候执行。。(非MainForm_SizeChanged)

C# code
        private void normalForm()//恢复
        {
            this.Visible = true;
            this.WindowState=FormWindowState.Normal;
        }
        private void minForm()//隐藏
           {
               WindowState = FormWindowState.Minimized;
               this.Visible = false;
               this.notifyIcon1.Visible = true; 
           }


------解决方案--------------------
C# code
private void Form1_SizeChanged(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {                
                this.Visible = false;//隐藏窗体
                this.notifyIcon1.Visible = true;//显示托盘图标
                this.notifyIcon1.Text = this.Text;//设置托盘文本                
            }           
        }