QQ窗口抖動

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QQ窗口抖動
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Size = new Size(1000,800);
            this.Left = Screen.PrimaryScreen.WorkingArea.Width / 2 - this.Width / 2;
            this.Top = Screen.PrimaryScreen.WorkingArea.Height / 2 - this.Height / 2;
            textBox1.ReadOnly = true;//設置爲只讀
            this.AcceptButton = button2;//回車發送消息

        }
        //窗口抖動button
        private void button1_Click(object sender, EventArgs e)
        {
            int x = this.Left;
            int y = this.Top;
            for (int i = 0; i < 5; i++)
            {
                this.Location = new Point(x-3,y);
                Thread.Sleep(20);
                this.Location = new Point(x-3,y-3);
                Thread.Sleep(20);
                this.Location = new Point(x , y-3);
                Thread.Sleep(20);
                this.Location = new Point(x + 3, y - 3);
                Thread.Sleep(20);
                this.Location = new Point(x +3, y);
                Thread.Sleep(20);
                this.Location = new Point(x +3, y + 3);
                Thread.Sleep(20);
                this.Location = new Point(x , y+3);
                Thread.Sleep(20);
                this.Location = new Point(x - 3, y +3);
                Thread.Sleep(20);
                this.Location = new Point(x - 3, y);
                Thread.Sleep(20);
                this.Location = new Point(x , y );
                Thread.Sleep(20);
            }
        }
        //發送button
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox2.Text!="")
            {
                textBox1.AppendText(DateTime.Now+"\r\n"+textBox2.Text+"\r\n");//文本追蹤  “\r\n”換行
                textBox2.Text = "";// textbox1.AppendText追蹤文本
            }
        }
    }
}

發佈了29 篇原創文章 · 獲贊 35 · 訪問量 553
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章