zoukankan      html  css  js  c++  java
  • Winform实现窗体抖动的效果代码


     Winform实现窗体抖动的效果代码,我们都知道,在目前的即时通讯工具中都有窗体抖动的功能,这也是为了及时通知对方而设立的功能,今天我们就用Winform的C#版来实现窗体拌动的功能!

    思路:间隔一定时间,改变窗体的位置,必须是围绕起始位置改变窗体位置,否则就成窗体移动了。

    代码如下:


    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)
            {

               //实现窗体抖动的效果
                Point first =this .Location;
                for (int i = 0; i < 8; i++)
                {
                    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(15);//当前线程挂起15毫秒
                    this.Location = p;
                    System.Threading.Thread.Sleep(15);//当前线程再挂起15毫秒

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

            }
        }
    }
     

  • 相关阅读:
    如何运用NLP技巧处理负面情绪
    寻找出路:企业高层面临的困境及对策
    星雨行
    职业发展:从基层到高层的“突破规律”
    老总必看:如何培养自己的“领袖气质”
    成功领导者的“整合性思维”,自己如何培养?
    杨晓芳(帮别人名字作诗)
    别舞动我的情觞
    卖月光
    创业如何找钱:越简单模式越容易成功
  • 原文地址:https://www.cnblogs.com/yja9010/p/3178816.html
Copyright © 2011-2022 走看看