溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

怎么用C#實現(xiàn)一個QQ聊天窗口

發(fā)布時間:2021-07-12 09:15:37 來源:億速云 閱讀:113 作者:Leah 欄目:開發(fā)技術(shù)

這期內(nèi)容當(dāng)中小編將會給大家?guī)碛嘘P(guān)怎么用C#實現(xiàn)一個QQ聊天窗口,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;// 用于暫停 的線程
namespace 聊天窗口
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        int x, y;// x為窗體left,y為窗體top
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width / 2 - this.Width / 2, Screen.PrimaryScreen.WorkingArea.Height / 2 - this.Height / 2);
            x = this.Left;
            y = this.Top;
            this.AcceptButton = button2; //按回車發(fā)送
            textBox1.ReadOnly = true; // 禁止輸入
            textBox1.ScrollBars = ScrollBars.Vertical; //顯示垂直滾動條
            textBox1.Font = new Font("", 16);
            textBox2.Font = new Font("", 16); 
        }
        int t = 5, space = 10;// t為暫停時間,space為移動距離

        //抖動
        private void button1_Click(object sender, EventArgs e)
        {  // 循環(huán)抖動
            for (int i = 0; i <5; i++)
            {  // 改變窗體位置
                this.Location = new Point(x - space, y);
                Thread.Sleep(t);
                this.Location = new Point(x - space, y - space);
                Thread.Sleep(t);
                this.Location = new Point(x, y - space);
                Thread.Sleep(t);
                this.Location = new Point(x + space, y - space);
                Thread.Sleep(t);
                this.Location = new Point(x + space, y);
                Thread.Sleep(t);
                this.Location = new Point(x + space, y + space);
                Thread.Sleep(t);
                this.Location = new Point(x, y + space);
                Thread.Sleep(t);
                this.Location = new Point(x - space, y + space);
                Thread.Sleep(t);
                this.Location = new Point(x - space, y);
                Thread.Sleep(t);
                this.Location = new Point(x, y);
            }
        }
        // 發(fā)送
        private void button2_Click(object sender, EventArgs e)
        { 
            // 記錄超出文本框高度 最新消息顯示
            textBox1.AppendText(DateTime.Now + "\r\n" + textBox2.Text + "\r\n");
            textBox2.Text = " ";// 文本框清空
        }

    }
}

上述就是小編為大家分享的怎么用C#實現(xiàn)一個QQ聊天窗口了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI