C#仿QQ聊天窗口
本文實(shí)例為大家分享了C#實(shí)現(xiàn)QQ聊天窗口的具體代碼,供大家參考,具體內(nèi)容如下
效果圖:

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; //顯示垂直滾動(dòng)條
textBox1.Font = new Font("", 16);
textBox2.Font = new Font("", 16);
}
int t = 5, space = 10;// t為暫停時(shí)間,space為移動(dòng)距離
//抖動(dòng)
private void button1_Click(object sender, EventArgs e)
{ // 循環(huán)抖動(dòng)
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 = " ";// 文本框清空
}
}
}
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
C#實(shí)現(xiàn)簡(jiǎn)單的JSON序列化功能代碼實(shí)例
這篇文章主要介紹了C#實(shí)現(xiàn)簡(jiǎn)單的JSON序列化功能,大家可以參考使用2013-11-11
C#簡(jiǎn)單實(shí)現(xiàn)發(fā)送socket字符串
這篇文章主要為大家詳細(xì)介紹了C#簡(jiǎn)單實(shí)現(xiàn)socket字符串發(fā)送,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-09-09
關(guān)于c#中枚舉類型支持顯示中文的擴(kuò)展說明
需求 : 枚舉類型在界面顯示的時(shí)候可以顯示相應(yīng)的中文信息, 這樣界面對(duì)用戶友好 . 場(chǎng)景?。骸≡谝恍I(yè)務(wù)中涉及到審核功能的時(shí)候, 往往有這幾個(gè)狀態(tài)?。何此蛯?, 審核中 ,審核通過, 駁回?。∵@個(gè)時(shí)候我們會(huì)定義一個(gè)枚舉類型來(lái)描述?。?/div> 2013-03-03
c#實(shí)現(xiàn)服務(wù)器性能監(jiān)控并發(fā)送郵件保存日志
這篇文章主要介紹了c#實(shí)現(xiàn)服務(wù)器性能監(jiān)控并發(fā)送郵件保存日志的示例,代碼分為客戶端和服務(wù)端,客戶端可安裝為本地服務(wù)形式啟動(dòng)2014-01-01
C#控制臺(tái)帶參數(shù)程序源碼編寫實(shí)例講解
像ipconfig /all 這樣的CMD命令想必大家都知道,但是很多童鞋可能不知道怎么寫這樣的控制臺(tái)帶參數(shù)的程序,需要的朋友可以了解下2012-12-12
DevExpress之餅狀圖突出(Explode)設(shè)置實(shí)例
這篇文章主要介紹了DevExpress之餅狀圖突出(Explode)設(shè)置方法,以實(shí)例形式展示了餅狀圖突出設(shè)置的具體實(shí)現(xiàn)過程,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2014-10-10最新評(píng)論

