C#实现窗体抖动

来源:互联网 发布:尔雅网络 编辑:程序博客网 时间:2024/05/16 12:08


using System;
using System.Drawing;
using System.Windows.Forms;

namespace twitter
{
   
public partial class Form1 : Form
    {
       
public Form1()
        {
            InitializeComponent();
        }

       
private void button1_Click(object sender, EventArgs e)
        {
            Random ran
= new Random((int)DateTime.Now.Ticks);
            Point point
= this.Location;
           
for (int i = 0; i < 40; i++)
            {
               
this.Location = new Point(point.X + ran.Next(8) - 4, point.Y + ran.Next(8) - 4);
                System.Threading.Thread.Sleep(
15);
               
this.Location = point;
                System.Threading.Thread.Sleep(
15);
            }
        }
    }
}