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;   //将窗体还原为原来的位置    

            }
        }
    }
     

  • 相关阅读:
    Python爬虫-05:Ajax加载的动态页面内容
    Python爬虫-04:贴吧爬虫以及GET和POST的区别
    Python-爬虫03:urllib.request模块的使用
    Python Numpy-基础教程
    8皇后算法
    迷宫算法
    归并排序
    查找算法
    排序算法
    设计模式
  • 原文地址:https://www.cnblogs.com/yja9010/p/3178816.html
Copyright © 2011-2022 走看看