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

C#winform缩小后,双击还原,无法实现类似QQ隐藏
代码实现的是类似QQ那种拖到边界会自动隐藏的效果,开始的时候就可以,但是
第一个问题::当我点击缩小按钮后,,,再次双击托盘(notifyIcon1)显示窗体时,就无法再次实现QQ自动隐藏效果。。。。请问下,怎么解决此问题。。。

第二个问题::怎么让窗体再次显示时是在屏幕中间??我加上(
this.WindowState=FormWindowState.Normal
)没效果,,还是显示在屏幕的左上角。。

        //窗体隐藏效果

        int form_MODE = 0, 
            form_T = 3, 
            form_XY = 6;


        private void form_hide_Tick(object sender, EventArgs e)
        {
            if (MouseButtons == MouseButtons.Left)
                return;

            int x = MousePosition.X, y = MousePosition.Y;

            if (x > (this.Location.X - form_XY)
                &&
                x < (this.Location.X + this.Width + form_XY)
                &&
                y > (this.Location.Y - form_XY)
                &&
                y < (this.Location.Y + this.Height + form_XY))
            {
                if (this.form_MODE == 1)
                    this.Location = new Point(form_T, this.Location.Y);
                else if (this.form_MODE == 2)
                    this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width - form_T, this.Location.Y);
                else if (this.form_MODE == 3)
                    this.Location = new Point(this.Location.X, form_T);
            }

            else//鼠标移动到窗口外,隐藏
            {
                if (this.Location.Y <= form_T)//上
      &n