C#实现窗体抖动功能- Focus on my subject! Powered by HendyZhu - 博客园

QQ2009版和2010版都有窗体抖动的功能

其实这个功能在C#中也可以实现。

改变窗体的位置,间隔一定时间,但必须是围绕起始位置改变窗体位置,否则就只是窗体的移动。

 

代码
 1 using System;
 2 using System.Drawing;
 3 using System.Windows.Forms;
 4 
 5 namespace HendyZhuBlog
 6 {
 7     public partial class Form1 : Form
 8     {
 9         public Form1()
10         {
11             InitializeComponent();
12         }
13 
14         private void button1_Click(object sender, EventArgs e)
15         {
16             Random ran = new Random((int)DateTime.Now.Ticks);
17             Point point = this.Location;
18             for (int i = 0; i < 40; i++)
19             {
20                 this.Location = new Point(point.X + ran.Next(8- 4, point.Y + ran.Next(8- 4);
21                 System.Threading.Thread.Sleep(10);
22                 this.Location = point;
23                 System.Threading.Thread.Sleep(10);
24             }
25         }
26     }
27 }

 

 

 

posted on 2010-06-23 00:13 阅读(5)  

郑重声明:资讯 【C#实现窗体抖动功能- Focus on my subject! Powered by HendyZhu - 博客园】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——