C#仿QQ聊天窗口
作者:Dust_SongYunfei 发布时间:2022-09-30 09:12:39
标签:C#,聊天窗口
本文实例为大家分享了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 = " ";// 文本框清空
}
}
}
来源:https://blog.csdn.net/dust__/article/details/103153945


猜你喜欢
- 本文实例讲述了C#串口通信实现方法。分享给大家供大家参考。具体方法如下:通过COM1发送数据,COM2接收数据。当COM2接收完本次发送的数
- 写在前面:使用springboot作为web框架,方便开发许多,做分布式开发,dubbo又不可少,那么怎么整合在一起呢,跟我学一遍,至少会用
- Flutter底部和顶部导航栏的实现,供大家参考,具体内容如下带文字图标的底部导航栏(使用BottomNavigationBar和Botto
- 本文主要介绍的是一个球形水波的百分比控件,市面上有各种形形色色的百分比控件,我一直觉得水波是最炫的,UI给了我这个机会,然而网上搜了一大堆,
- 有时候如果想让我们的应用在桌面上创建多个快捷方式,我们可以在Manifest.xml文件中对相应的activity进行声明。<appl
- Alt+Enter快捷键是Idea中比较特殊的一个快捷键。它有很多功能,比如:导入包,自动修正代码 解决出现的问题 也可以生成返回值。这里有
- 本文实例讲述了Hibernate实现批量添加数据的方法。分享给大家供大家参考,具体如下:1.Hibernate_016_Ba
- 前言最近项目中需要用到字符串加解密,遂研究了一波,发现密码学真的是博大精深,好多算法的设计都相当巧妙,学到了不少东西,在这里做个小小的总结,
- 本文实例讲述了C#实现动态加载dll的方法。分享给大家供大家参考。具体实现方法如下:using System;using System.Co
- tcp客户端示例#include <errno.h> #include <sys/socket.h> #includ
- 简单工厂简单工厂模式是属于创建型模式,是工厂模式的一种。简单工厂模式是由一个工厂对象决定创建出哪一种产品类的实例。定义了一个创建对象的类,由
- .Net的System.Net.Sockets.TcpClient和System.Net.Sockets.Socket都没有直接为Conne
- 文章来源:csdn 作者:wangfengsdu经常听到回调函数(callback function)这个概念, 所谓回调函数,就是指这个函
- 首先是获取特定进程对象,可以使用Process.GetProcesses()方法来获取系统中运行的所有进程,或者使用Process.GetC
- 我就废话不多说了,大家还是直接看代码吧~ public List<FreightM> sortList(List&l
- 前段时间做课程作业网站后端,运用Spring boot+MyBatis的框架进行设计,Postman进行接口的检测,出现了一些问题。出现的问
- 一、为什么要控制当你在项目启动时需要提前做一个业务的初始化工作时,或者你正在开发某个中间件需要完成自动装配时。你会声明自己的Configur
- Android获取系统cpu信息,内存,版本,电量等信息 1、CPU频率,CPU信息:/proc/cpuinfo和/proc/stat 通过
- 本文实例讲述了Android开发之SD卡文件操作。分享给大家供大家参考,具体如下:前面的文章中写过直接操作手机自带存储器的程序,这次就接着上
- idea默认带的equals和hashcode引起的bug最近因规范需要,统一使用idea,使用的版本为2017.4.建立一个实体类,在添加