C#仿QQ聊天窗口
作者:Dust_SongYunfei 时间:2022-09-30 09:12:39
本文实例为大家分享了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#,聊天窗口
0
投稿
猜你喜欢
基于ChatGPT+SpringBoot实现智能聊天AI机器人接口并上线至服务器的方法
2023-07-01 06:19:34
Android系统制作自定义签名的例子
2023-02-02 05:10:04
Android Support Library 标题栏(Toolbar)滚动效果实现方法
2022-10-24 03:25:12
通过C#程序操作Config文件
2023-11-30 14:24:06
C# GDI+实现时钟表盘
2023-06-20 07:11:32
Android10填坑适配指南(实际经验代码)
2022-10-05 19:51:19
Intellij IDEA创建spring-boot项目的图文教程
2022-06-15 01:09:59
SpringBoot+Eureka实现微服务负载均衡的示例代码
2021-09-19 07:10:13
使用Springboot搭建OAuth2.0 Server的方法示例
2023-01-28 07:19:16
Flutter有状态组件StatefulWidget生命周期详解
2023-09-25 23:56:50
Android实现向Launcher添加快捷方式的方法
2022-09-14 09:26:41
git版本回退_动力节点Java学院整理
2022-06-21 13:26:10
Android自定义View实现竖直跑马灯效果案例解析
2021-06-25 04:04:30
浅谈Java获得多线程的返回结果方式(3种)
2023-04-02 05:37:36
Android中使用七牛云存储进行图片上传下载的实例代码
2023-12-17 11:56:35
Java中的synchronized关键字
2023-07-28 18:39:26
Android 中StringBuffer 和StringBuilder常用方法
2023-10-29 08:39:26
android TextView设置中文字体加粗实现方法
2023-08-06 02:32:03
Android 媒体库数据更新方法总结
2022-04-24 10:22:17
C#多态详解
2023-06-25 13:42:20