大家好 QQ的窗体 当你移动到屏幕最上面的时候 他会自动隐藏起来 你就只看得到一条线 当你鼠标移动过去的时候 他又会自动垂下来 请问如何实现?? (最好来段代码)

解决方案 »

  1.   

    我觉得可以这么实现:
    1,用一个计时器,每隔一段时间去检查一下窗体是否active,如果不是,则改变this.Size和this.Position
    2,在OnMouseEnter的消息处理函数中将窗口恢复原大小。
      

  2.   

    当OnMouseLeave时..窗SIZE变化成很小..Location值设置成你需要的位置(比如屏幕几周某处)
    OnMouseEnter时...窗体大小还原
      

  3.   


    /// <summary>
    /// 说明:窗口靠边隐藏与显示,没有返回值。
    /// </summary>
    /// <param name="Forms">说明:目标窗口,类型:System.Windows.Forms.Form。</param>
    /// <param name="FormsHeight">说明:目标窗口高度,类型:System.Int32。</param>
    public static void SideHideOrShow(Form Forms, ref int FormsHeight)
    {
        if (Forms.WindowState != FormWindowState.Minimized)
        {
            if (Cursor.Position.X > Forms.Left - 1 && Cursor.Position.X < Forms.Right && Cursor.Position.Y > Forms.Top - 1 && Cursor.Position.Y < Forms.Bottom)
            {
                if (Forms.Top <= 0 && Forms.Left > 5 && Forms.Left < Screen.PrimaryScreen.WorkingArea.Width - Forms.Width)
                {
                    Forms.Top = 0;
                }
                else if (Forms.Left <= 0)
                {
                    Forms.Top = 0;
                    Forms.Left = 0;
                    Forms.Height = Screen.PrimaryScreen.WorkingArea.Height;
                }
                else if (Forms.Left + Forms.Width >= Screen.PrimaryScreen.WorkingArea.Width)
                {
                    Forms.Top = 0;
                    Forms.Left = Screen.PrimaryScreen.WorkingArea.Width - Forms.Width;
                    Forms.Height = Screen.PrimaryScreen.WorkingArea.Height;
                }
                else
                {
                    if (FormsHeight > 0)
                    {
                        Forms.Height = FormsHeight;
                        FormsHeight = 0;
                    }
                }
            }
            else
            {
                if (FormsHeight < 1)
                {
                    FormsHeight = Forms.Height;
                }
                if (Forms.Top <= 4 && Forms.Left > 5 && Forms.Left < Screen.PrimaryScreen.WorkingArea.Width - Forms.Width)
                {
                    Forms.Top = 3 - Forms.Height;
                    if (Forms.Left <= 4)
                    {
                        Forms.Left = -5;
                    }
                    else if (Forms.Left + Forms.Width >= Screen.PrimaryScreen.WorkingArea.Width - 4)
                    {
                        Forms.Left = Screen.PrimaryScreen.WorkingArea.Width - Forms.Width + 5;
                    }
                }
                else if (Forms.Left <= 4)
                {
                    Forms.Left = 3 - Forms.Width;
                }
                else if (Forms.Left + Forms.Width >= Screen.PrimaryScreen.WorkingArea.Width - 4)
                {
                    Forms.Left = Screen.PrimaryScreen.WorkingArea.Width - 3;
                }
            }
        }
    }//实现:(添加一个 Timer 控件) //程序代码private int FormsHeight = 0;private void timerAutoHide_Tick(object sender, EventArgs e)
    {
                IrisSkin.SideHideOrShow(this, ref FormsHeight);
                Application.DoEvents();
    }
      

  4.   

    BIGBIRDINWOODS
    你从哪粘来的代码,运行后根本没有任何作用啊!
      

  5.   

    把窗口名换掉终于可以了,但是这个是改height属性的,要是能改坐标实现缩放的动画就好了,不过还是谢谢了