不就是让窗体的location晃动一下吗

解决方案 »

  1.   

    是否是用timer启发窗体坐标短时间变化?我也是新手以上只是我个人想法
      

  2.   

    private void button2_Click(object sender, EventArgs e)
            {
                int recordx = this.Left;
                int recordy = this.Top;
                Random random = new Random();
                for (int i = 0; i < 50; i++)
                {
                    int x = random.Next(rand);
                    int y = random.Next(rand);
                    if (x % 2 == 0)
                    {
                        this.Left = this.Left + x;
                    }
                    else
                    {
                        this.Left = this.Left - x;
                    }
                    if (y % 2 == 0)
                    {
                        this.Top = this.Top + y;
                    }
                    else
                    {
                        this.Top = this.Top - y;
                    }
                    System.Threading.Thread.Sleep(1);
                }
                this.Left = recordx;
                this.Top = recordy;
            }
      

  3.   

    private void button2_Click(object sender, EventArgs e)
            {
                int recordx = this.Left;
                int recordy = this.Top;
                Random random = new Random();
                for (int i = 0; i < 50; i++)
                {
                    int x = random.Next(rand);
                    int y = random.Next(rand);
                    if (x % 2 == 0)
                    {
                        this.Left = this.Left + x;
                    }
                    else
                    {
                        this.Left = this.Left - x;
                    }
                    if (y % 2 == 0)
                    {
                        this.Top = this.Top + y;
                    }
                    else
                    {
                        this.Top = this.Top - y;
                    }
                    System.Threading.Thread.Sleep(1);
                }
                this.Left = recordx;
                this.Top = recordy;
            }
    看看MyQQ。
      

  4.   

    double dob = 0;
            private void timer1_Tick(object sender, EventArgs e)
            {
                //每次增加角度数
                dob += 30;
                //数字3为窗口抖动的半径
                this.Location = new Point(this.Location.X +Convert.ToInt32( Math.Sin(dob)*3), this.Location.Y +Convert.ToInt32( Math.Cos(dob)*3));
                if(dob>720)
                {
                    dob = 0;
                    timer1.Enabled = false;   
                }
            }
      

  5.   

    double dob = 0;
            private void timer1_Tick(object sender, EventArgs e)
            {
                //每次增加角度数
                dob += 30;
                //数字3为窗口抖动的半径
                this.Location = new Point(this.Location.X +Convert.ToInt32( Math.Sin(dob)*3), this.Location.Y +Convert.ToInt32( Math.Cos(dob)*3));
                if(dob>720)
                {
                    dob = 0;
                    timer1.Enabled = false;   
                }
            }