Form1_MouseLeave 时
窗体.left--; 或 窗体.left++;
直到移出右屏幕或左屏幕然后全屏检测鼠标位置
当位置= form.location - 50 或 + 50 时 this.left = 100 //或者再做滑出效果不就行了

解决方案 »

  1.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    /*
     * 算法简述(主要分为如下三个步骤):
     * 
     * 1、首先将该按钮上面的按钮推上去(相当于点击被“推上去”的这个按钮),在推动的过程中,
     *    如果被推动的按钮的上面还有另一个按钮,则重复这个过程(步骤 1)
     * 2、然后将自己推上去
     * 3、最后将该按钮下面的按钮推下去(相当于点击被“推下去”的这个按钮),在推动的过程中,
     *    如果被推动的按钮的上面还有另一个按钮,则重复这个过程(步骤 3)
     * 
     * 整个过程就像你站在队伍中,你想前进,首先你得告诉站在你前面的人前进,然后你必须等待,直到你前面的人
     * 前进之后你才能够前进。(你前面的人同样必须和你做同样的事,这个过程直到传达到第一个人为止)
     * 
     * 
     * 
     * 还没有明白吗?没关系,我们来举例说明这个算法:
     * 为了方便理解程序,我们以“按钮1”、“按钮2”、“按钮3”和“按钮4”这四个从上到下依次排列的按钮为例,
     * 我们假设“按钮3”被点击:
     * 1、将“按钮1”推到最顶端
     * 2、将“按钮2”推到“按钮1”的下方。
     * 3、将自己(“按钮3”)推上去;
     * 4、将“按钮4”推下去。
     * 
     * 
     * 本程序中主要运用了属性的特点。
     * 因为使用的是中文编程,所以就不再详细说明了。
     */
    namespace QQ3000
    {
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.GroupBox groupBox1;
    private System.Windows.Forms.Button 按钮_我的好友;
    private System.Windows.Forms.Button 按钮_陌生人;
    private System.Windows.Forms.Button 按钮_黑名单;

    private int 陌生人
    {
    get
    {
    return 按钮_陌生人.Top;
    }
    set
    {
    if( value < 按钮_陌生人.Top )
    {
    按钮_陌生人.Top = 按钮_我的好友.Top + 按钮_我的好友.Height;
    }
    else
    {
    黑名单 ++;
    按钮_陌生人.Top = 按钮_黑名单.Top - 按钮_陌生人.Height;
    }
    }
    }
    private int 黑名单
    {
    get
    {
    return 按钮_黑名单.Top;
    }
    set
    {
    if( value < 按钮_黑名单.Top )
    {
    陌生人 --;
    按钮_黑名单.Top = 按钮_陌生人.Bottom + 1;
    }
    else
    {
    按钮_黑名单.Top = groupBox1.Height - 按钮_陌生人.Height;
    }
    }
    }
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null; public Form1()
    {
    //
    // Required for Windows Form Designer support
    //
    InitializeComponent(); //
    // TODO: Add any constructor code after InitializeComponent call
    //
    } /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.按钮_黑名单 = new System.Windows.Forms.Button();
    this.按钮_陌生人 = new System.Windows.Forms.Button();
    this.groupBox1 = new System.Windows.Forms.GroupBox();
    this.按钮_我的好友 = new System.Windows.Forms.Button();
    this.groupBox1.SuspendLayout();
    this.SuspendLayout();
    // 
    // 按钮_黑名单
    // 
    this.按钮_黑名单.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    | System.Windows.Forms.AnchorStyles.Right);
    this.按钮_黑名单.Location = new System.Drawing.Point(0, 48);
    this.按钮_黑名单.Name = "按钮_黑名单";
    this.按钮_黑名单.Size = new System.Drawing.Size(97, 24);
    this.按钮_黑名单.TabIndex = 2;
    this.按钮_黑名单.Text = "黑 名 单";
    this.按钮_黑名单.Click += new System.EventHandler(this.按钮_黑名单_单击);
    // 
    // 按钮_陌生人
    // 
    this.按钮_陌生人.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    | System.Windows.Forms.AnchorStyles.Right);
    this.按钮_陌生人.Location = new System.Drawing.Point(0, 24);
    this.按钮_陌生人.Name = "按钮_陌生人";
    this.按钮_陌生人.Size = new System.Drawing.Size(97, 24);
    this.按钮_陌生人.TabIndex = 1;
    this.按钮_陌生人.Text = "陌 生 人";
    this.按钮_陌生人.Click += new System.EventHandler(this.按钮_陌生人_单击);
    // 
    // groupBox1
    // 
    this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    | System.Windows.Forms.AnchorStyles.Right);
    this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
    this.按钮_黑名单,
    this.按钮_陌生人,
    this.按钮_我的好友});
    this.groupBox1.Location = new System.Drawing.Point(8, 8);
    this.groupBox1.Name = "groupBox1";
    this.groupBox1.Size = new System.Drawing.Size(97, 352);
    this.groupBox1.TabIndex = 0;
    this.groupBox1.TabStop = false;
    // 
    // 按钮_我的好友
    // 
    this.按钮_我的好友.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    | System.Windows.Forms.AnchorStyles.Right);
    this.按钮_我的好友.Name = "按钮_我的好友";
    this.按钮_我的好友.Size = new System.Drawing.Size(97, 24);
    this.按钮_我的好友.TabIndex = 0;
    this.按钮_我的好友.Text = "我 的 好 友";
    this.按钮_我的好友.Click += new System.EventHandler(this.按钮_我的好友_单击);
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(113, 378);
    this.Controls.AddRange(new System.Windows.Forms.Control[] {
      this.groupBox1});
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
    this.MaximizeBox = false;
    this.MinimizeBox = false;
    this.Name = "Form1";
    this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
    this.Text = "QQ3000";
    this.groupBox1.ResumeLayout(false);
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private void 按钮_我的好友_单击(object sender, System.EventArgs e)
    {
    陌生人 ++;
    } private void 按钮_陌生人_单击(object sender, System.EventArgs e)
    {
                陌生人 --;
    黑名单 ++;
    } private void 按钮_黑名单_单击(object sender, System.EventArgs e)
    {
    陌生人 --;
    黑名单 --;
    }
    }
    }
      

  2.   

    这个问题比较麻烦,所以我这是说说我的思路。
    设置一个Mouse Hook,这样你窗体上面有控件也不会检测不到鼠标。
    然后在回调函数中,检测WM_MOUSEMOVE(0x0200)事件,判断Cursor.Position,然后要实现滑动效果,可以调用AnimateWindow来实现。
    具体参考这两个帖子:怎么把窗体做成像QQ那样,屏幕贴边自动隐藏????
    http://expert.csdn.net/Expert/TopicView3.asp?id=1449772
    C#如何实现窗口的淡入淡出效果?(AnimateWindow)
    http://expert.csdn.net/Expert/TopicView3.asp?id=1199603
      

  3.   

    我的第一版:看看怎样?
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.Threading ;namespace LikeQQ
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null;
    private bool ok; public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(268, 266);
    this.Name = "Form1";
    this.Text = "Form1";
    this.Load += new System.EventHandler(this.Form1_Load);
    this.MouseHover += new System.EventHandler(this.Form1_MouseHover);
    this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
    this.MouseEnter += new System.EventHandler(this.Form1_MouseEnter);
    this.MouseLeave += new System.EventHandler(this.Form1_MouseLeave); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private void Form1_Load(object sender, System.EventArgs e)
    {

    } private void Form1_MouseLeave(object sender, System.EventArgs e)
    {
    if(StationTop())
    {
    Thread myT=new Thread (new System .Threading .ThreadStart(ReduceEffect));
    myT.Start ();
    }

    }
    private bool StationTop()
    {
    if (this.Top <=0)
    return true;
    else
    return false;
    }
    private void ReduceEffect()
    {
    if(ok)
    {
    }
    else
    {
    for(;;)
    {
    if (this.Height +this.Top <=20)
    {
    break;
    }
    else
    {
    Application.DoEvents ();
    this.Top -=1;
    Application.DoEvents ();
    Thread.Sleep(1);
    Application.DoEvents(); }
    }
    } }
    private void AddEffect()
    {
    ok=true;
    for(;;)
    {
    if (this.Top >=0)
    {ok=false;
    break;
    }
    else
    {
    Application.DoEvents ();
    this.Top +=1;
    Application.DoEvents ();
    Thread.Sleep(1);
    Application.DoEvents(); }
    }
    } private void Form1_MouseEnter(object sender, System.EventArgs e)
    {


    } private void Form1_MouseHover(object sender, System.EventArgs e)
    {
    if(StationTop())
    {
    Thread myTT=new Thread (new System .Threading .ThreadStart(AddEffect));
    myTT.Start ();
    }
    } private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {

    }
    }
    }
      

  4.   

    我的第四版,还有部分功能实现的不是太好,不过可以凑合了。
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.Threading ;namespace LikeQQ4
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null;
    private bool specialMin;
    private int modirection; public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(193, 527);
    this.Name = "Form1";
    this.Text = "Form1";
    this.MouseHover += new System.EventHandler(this.Form1_MouseHover);
    this.Activated += new System.EventHandler(this.Form1_Activated);
    this.Deactivate += new System.EventHandler(this.Form1_Deactivate); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    }
    private bool StayAtTop()
    {
    if (this.Top <=0)
    return true;
    else
    return false;
    }
    private void move()
    {
    if(StayAtTop())

    for(;;)
    {

    if (modirection==1)
    {
    if(this.Top +this.Height <=10)
    {
    specialMin=true;
    break;
    }
    else
    {
    //向上滚动
    this.Top -=1;
    } }
    else
    {
    if(this.Top ==0)
    {
    specialMin=false;
    this.Activate();
    break;
    }
    else
    {
    //向下滚动
    this.Top +=1;
    } }
    }


    }

    } private void Form1_Activated(object sender, System.EventArgs e)
    {
    if(StayAtTop())
     {
     if(specialMin)
     modirection=2;
     Thread myT=new Thread (new System.Threading .ThreadStart(move));
     System.Threading .Monitor.Enter (myT);
     myT.Start ();
     }

    } private void Form1_Deactivate(object sender, System.EventArgs e)
    {
    if(StayAtTop())
    {
    if(specialMin==false)
    modirection=1;
    Thread myT=new Thread (new System.Threading .ThreadStart(move));
    System.Threading .Monitor.Enter (myT);
    myT.Start ();
    }

    } private void Form1_MouseHover(object sender, System.EventArgs e)
    {
    if(StayAtTop())
    {
    if(specialMin)
    modirection=2;
    Thread myT=new Thread (new System.Threading .ThreadStart(move));
    System.Threading .Monitor.Enter (myT);
    myT.Start ();
    }
    }
    }
    }
      

  5.   

    说明一下:LikeQQ4基本功能可以实现,我已经在我的程序中加入了这个部分,不过,有时候这个程序还是有点不稳定。主要出现在破坏性测试此功能上。