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

            }
        }
    }
     

  • 相关阅读:
    jmeter元件的执行顺序
    jmeter json path espressions学习
    性能测试常见瓶颈分析及调优方法
    jmeter 聚合报告参数解释
    Jmeter 使用正则表达式提取响应结果中的值
    前端所需要了解的东西
    webpack4导入jQuery的新方案
    react服务端渲染SSR实战
    使用await写异步优化代码
    Provider
  • 原文地址:https://www.cnblogs.com/yja9010/p/3178816.html
Copyright © 2011-2022 走看看