先上图:这里类似于QQ自己上卷的程序,定义了MouseEnter和MouseLeave两个主要事件。
可是,当程序卷上去后, 鼠标再移到程序下部分,这时程序卷出来,鼠标如果指向画红框中那些区域,会重复卷下卷上。这怎么处理呀,请救啊。谢谢
我把所有的代码发出来吧:
 public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }        //鼠标离开事件
        private void Form1_MouseLeave(object sender, EventArgs e)
        {            if (this.Location.Y == 0)
            {
                MoveFormHide();
            }
        }        //鼠标进入事件
        private void Form1_MouseEnter(object sender, EventArgs e)
        {
            if (this.Location.Y < 0)
            {
                MoveFormShow();
            }
        }
        //隐藏
        private void MoveFormHide()
        {
            int step = this.Size.Height / 10;
            for (int i = 0; i < 10; i++)
            {
                this.Location = new Point(this.Location.X, 0 - i * step);
                System.Threading.Thread.Sleep(50);
            }
        }        //显示
        private void MoveFormShow()
        {
            this.Location = new Point(this.Location.X, 0);
        }
        //以下为测试
        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            this.Text = string.Format("x={0},y={1}", e.X, e.Y);
        }        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            if (this.Location.Y <= 0)
            {
                this.Location = new Point(this.Location.X, 0);
            }
        }
    }