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
0
投稿
猜你喜欢
- 1、深度总结引用一位网友的话,说的非常好,如果别人问你static的作用;如果你说静态修饰 类的属性 和 类的方法 别人认为你是合格的;如果
- 项目开发中为了保护用户隐私安全,一般都会用MD5进行密码加密以下就简单举例SpringBoot 实现Mysql使用MD5进行密码加密做一个简
- 前言:使用 interrupt 来通知线程停止运行,而不是强制停止!普通情况停止线程public class Right
- Nacos简介Nacos 英文全称为 Dynamic Naming and Configuration Service,是一个由阿里巴巴团队
- 大家好,在这篇文章中,我们将学习如何添加动画,同时从一个页面到其他在 Flutter。我们将覆盖不同类型的动画和实现基本动画 Flutter
- 本文实例为大家分享了swing登录注册界面展示的具体代码,供大家参考,具体内容如下开发环境:Eclipse Neon.3 Release (
- @pathvariable与@requestparam碰到的一些问题一、@pathvariable可以将 URL 中占位符参数绑定到控制器处
- 这是一个及其常见的问题,网上已经有关于这个问题的很多讨论。但是我觉得都是不求甚解,有一些还是在误导别人。下面我来说下我对这三者的理解,如有错
- Maven修改打包文件名称对Maven打出的jar包名称不满意:想通过修改配置给jar包改名,查询找到了方法:pom.xml的<bui
- 简单理解泛型泛型是Java SE 1.5的新特性,泛型的本质是参数化类型,也就是说所操作的数据类型被指定为一个参数。通俗点将就是“类型的变量
- 1 前言任何一门语言都需要基本的流程控制语句,其思想也符合人类判断问题或做事的逻辑过程。什么是流程控制呢?流程就是做一件事情的顺序,或者说是
- 如下所示://view重绘时回调view.getViewTreeObserver().addOnDrawListener(new OnDra
- springboot集成 redispom文件<dependency> <groupId>
- 本文主要为大家整理Java常见的面试题,供大家参考,具体内容如下1. Java中sleep和wait的区别① 这两个方法来自不同
- 本文为大家分享两个实例,相信大家一定会喜欢。实例1:随机生成验证码图片并将之输出为一个png文件效果图:import java.awt.Co
- Java基础将Bean属性值放入Map中的实例利用发射将Java对象的属性值以属性名称为键,存储到Map中的简单实现。包括自身属性及从父类继
- Mapper:@Mapper@OracleRepositorypublic interface OracleRadiusMapper{@In
- 在Mybatis的动态SQL和${}形式的参数中都用到了OGNL表达式。Mybatis常用的OGNL表达式如下1、e1 or e2:或<
- 前言项目使用redis作为缓存数据,但面临着问题,比如,项目A,项目B都用到redis,而且用的redis都是一套集群,这样会带来一些问题。
- MD5加密简介哈希算法又称散列算法,是将任何数据转换成固定长度的算法的统称。 从本质上讲,MD5也是一种哈希算法,其输出是生成12