您好,登錄后才能下訂單哦!
這期內容當中小編將會給大家帶來有關怎么用C#實現一個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.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; //按回車發送 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) { // 循環抖動 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); } } // 發送 private void button2_Click(object sender, EventArgs e) { // 記錄超出文本框高度 最新消息顯示 textBox1.AppendText(DateTime.Now + "\r\n" + textBox2.Text + "\r\n"); textBox2.Text = " ";// 文本框清空 } } }
上述就是小編為大家分享的怎么用C#實現一個QQ聊天窗口了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。