如现在位置为:CPoint(30,21)
那如何动画移动到CPoint(620,870)
呢?要求水平坐标与纵坐标同步移动,不要先移动X到指定位置,再移动Y的值 !

解决方案 »

  1.   

    private   void   Form1_Move(object   sender,   System.EventArgs   e) 

    Rectangle   clipRectangle=new   Rectangle(200,200,300,300); 
    ClipCursor(ref   clipRectangle); 

    show是LOCATION
      

  2.   

    http://topic.csdn.net/u/20100226/23/1c3cddc3-2bc3-4e00-a342-5a17445b1933.html        private void Form1_Load(object sender, EventArgs e)
            {
                this.Location = p1;        }        Point p1 = new Point(30,21);
            Point p2 = new Point(420, 470);
            private void button1_Click(object sender, EventArgs e)
            {
                MoveTo(this, p2, 1, 50);
            }        /// <summary>
            /// 将指定控件移动到指定位置
            /// </summary>
            /// <param name="c">控件</param>
            /// <param name="p">目标位置(父容器坐标系)</param>
            /// <param name="movestep">移动次数</param>
            /// <param name="time">移动耗时</param>
            /// <res></res>
            public void MoveTo(Control c, Point p, int movestep, int time)
            {
                Point l = c.Location;
                float xspeed = (p.X - l.X) / movestep;
                float yspeed = (p.Y - l.Y) / movestep;
                float steptime = time; //1000 * time / movestep;
                for (int i = 1; i <= movestep; i++)
                {
                    c.Left = (int)(l.X + i * xspeed);
                    c.Top =(int)( l.Y + i * yspeed);
                    System.Threading.Thread.Sleep((int)steptime);
                    Application.DoEvents();
                }
            }