求这段代码最好能给个说明或者注释··   就是当窗体靠近windows窗体时候自动隐藏上去··估计大家都见过吧 就和QQ一样··  希望给个代码 最好短点的·加说明的谢谢··

解决方案 »

  1.   

    我也想知道,期待大虾们的答案ing。呵呵
      

  2.   

    取鼠标move事件.
     判断. 当坐标点x,或者y 一旦有个到了0
      就可以将他的大小改成0,1
      当鼠标移到他上面的时候.就把他大小还原.
      中间建两个变量存储他的状态和.原大小..
       不知道这么说 行不..
      

  3.   

      我在北大青鸟做项目的时候也用到了 我把代码给你了  我们过几天项目答辩了!
    ~  
     private void timFormBerth_Tick(object sender, EventArgs e)  //窗口停靠伸缩算法
            {
                if (WindowState != FormWindowState.Minimized)
                {
                    int ScreenWidth = Screen.PrimaryScreen.WorkingArea.Width;  //屏幕宽度 
                    int ScreenRight = Screen.PrimaryScreen.WorkingArea.Right; //屏幕高度 
                    int MouseX = Control.MousePosition.X; //鼠标X位置
                    int MouseY = Control.MousePosition.Y;//鼠标垂直位置
                    if (this.Left < 0 && this.Top < 0)
                    {
                        this.Left = 0;
                        this.Top = 1;
                    }
                    if (this.Left >= ScreenWidth - this.Right && this.Top < 0) //如果自己的左边是否在屏幕的边缘
                    {
                        this.Left = ScreenWidth;
                        this.Top = 0;
                    }
                    if (this.Top < 0 && MouseX > this.Left && MouseX < this.Left + this.Width && MouseY < 3)
                    {
                        this.Top = 0;
                    }
                    if (this.Top <= 0 && this.Left > 0 && this.Left < ScreenWidth - this.Width)
                    {
                        if (MouseX < this.Left || MouseX > this.Left + this.Width || MouseY > this.Top + this.Right)
                        {
                            this.Top = 3 - this.Right;
                        }
                    }
                    if (this.Left < 0 && MouseY > this.Top && MouseY < this.Top + this.Width && MouseX < 3)
                    {
                        this.Left = 0;
                    }
                    if (this.Left <= 0 && this.Top > 0 && this.Top < ScreenRight - this.Right)
                    {
                        if (MouseY < this.Top || MouseY > this.Top + this.Right || MouseX > this.Width)
                        {
                            this.Left = 3 - this.Width;
                        }
                    }
                    if (this.Left >= ScreenWidth - this.Width && this.Top > 0 && this.Top < ScreenRight - this.Width)
                    {
                        if (MouseY < this.Top || MouseY > this.Top + this.Right || MouseX < ScreenWidth - this.Width)
                        {
                            this.Left = ScreenWidth - 3;
                        }
                    }                if (this.Left > ScreenWidth - 5) //判断自己的左边是否隐藏了
                    {
                        if (MouseX > ScreenWidth - 5)  //如果隐藏了  判断鼠标是不在屏幕的边缘
                        {
                            this.Left = ScreenWidth - this.Width;
                        }
                    }
                }        }