winform窗体抖动

 private void button1_Click(object sender, EventArgs e)
    {
      //实现窗体抖动的效果
      Point first = this.Location;
      for (int i = 0; i < 50; i++)
      {
        Application.DoEvents();
        Random ran = new Random();
        Point p = new Point(this.Location.X + ran.Next(10) - 4, this.Location.Y +
            ran.Next(10) - 4);
        System.Threading.Thread.Sleep(10);//当前线程再挂起15毫秒
        this.Location = p;
        System.Threading.Thread.Sleep(10);//当前线程再挂起15毫秒
        Application.DoEvents();

      }
      this.Location = first;   //将窗体还原为原来的位置    
    }

 

posted on 2015-10-20 11:19  酒歌  阅读(460)  评论(0编辑  收藏  举报