服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - C# - C#仿QQ聊天窗口

C#仿QQ聊天窗口

2022-11-25 12:19Dust_SongYunfei C#

这篇文章主要为大家详细介绍了C#仿QQ聊天窗口,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了C#实现QQ聊天窗口的具体代码,供大家参考,具体内容如下

效果图:

C#仿QQ聊天窗口

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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#C#实现PDF文件添加图片背景

    C#实现PDF文件添加图片背景

    这篇文章主要介绍了C#实现PDF文件添加图片背景的相关资料,需要的朋友可以参考下...

    C#教程网8902021-11-12
  • C#C# winform 模拟键盘输入自动接入访问网络的实例

    C# winform 模拟键盘输入自动接入访问网络的实例

    本篇文章主要介绍了C# winform 模拟键盘输入自动接入访问网络,有兴趣的可以了解一下。...

    vicky liang11472021-12-10
  • C#C#实现两个窗体之间数值传送的方法

    C#实现两个窗体之间数值传送的方法

    这篇文章主要介绍了C#实现两个窗体之间数值传送的方法,涉及C#中WinForm窗体数值传递的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下...

    期待秋天的叶5302021-11-05
  • C#c# 基于GMap.NET实现电子围栏功能(WPF版)

    c# 基于GMap.NET实现电子围栏功能(WPF版)

    这篇文章主要介绍了c# 基于GMap.NET实现电子围栏功能(WPF版),帮助大家更好的理解和学习使用c#,感兴趣的朋友可以了解下...

    源之缘4412022-11-07
  • C#C# 设计模式系列教程-桥接模式

    C# 设计模式系列教程-桥接模式

    桥接模式降低了沿着两个或多个维度扩展时的复杂度,防止类的过度膨胀,解除了两个或多个维度之间的耦合,使它们沿着各自方向变化而不互相影响。...

    Wang Juqiang5892021-11-23
  • C#Unity实现领取奖励特效

    Unity实现领取奖励特效

    这篇文章主要为大家详细介绍了Unity实现领取奖励特效,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...

    LLLLL__4092022-10-12
  • C#C#中List和SortedList的简介

    C#中List和SortedList的简介

    今天小编就为大家分享一篇关于C#中List和SortedList的简介,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看...

    Czhenya6962022-03-03
  • C#C# 拷贝数组的几种方法(总结)

    C# 拷贝数组的几种方法(总结)

    下面小编就为大家带来一篇C# 拷贝数组的几种方法(总结)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...

    C#教程网9452021-12-03