用c#.net写一个微信界面,不需要功能,只需要界面
时间: 2024-03-29 12:41:37 浏览: 15
好的,以下是一个简单的微信界面的C#代码,只有界面,没有功能:
```csharp
using System;
using System.Windows.Forms;
namespace WeChatInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Text = "微信";
this.Width = 600;
this.Height = 800;
this.FormBorderStyle = FormBorderStyle.FixedSingle;
// 上面的标题栏
Panel panelTitle = new Panel();
panelTitle.Dock = DockStyle.Top;
panelTitle.Height = 50;
panelTitle.BackColor = System.Drawing.Color.FromArgb(0, 122, 204);
this.Controls.Add(panelTitle);
// 标题栏上的关闭按钮
Button btnClose = new Button();
btnClose.Text = "×";
btnClose.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
btnClose.ForeColor = System.Drawing.Color.White;
btnClose.FlatStyle = FlatStyle.Flat;
btnClose.BackColor = System.Drawing.Color.FromArgb(0, 122, 204);
btnClose.FlatAppearance.BorderSize = 0;
btnClose.Dock = DockStyle.Right;
btnClose.Width = 50;
btnClose.Height = 50;
btnClose.Click += BtnClose_Click;
panelTitle.Controls.Add(btnClose);
// 标题栏上的标题
Label lblTitle = new Label();
lblTitle.Text = "微信";
lblTitle.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
lblTitle.ForeColor = System.Drawing.Color.White;
lblTitle.Dock = DockStyle.Fill;
lblTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
panelTitle.Controls.Add(lblTitle);
// 左侧的联系人列表
ListBox listBoxContacts = new ListBox();
listBoxContacts.Dock = DockStyle.Left;
listBoxContacts.Width = 200;
listBoxContacts.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
listBoxContacts.Items.Add("联系人1");
listBoxContacts.Items.Add("联系人2");
listBoxContacts.Items.Add("联系人3");
listBoxContacts.Items.Add("联系人4");
listBoxContacts.Items.Add("联系人5");
listBoxContacts.Items.Add("联系人6");
listBoxContacts.Items.Add("联系人7");
listBoxContacts.Items.Add("联系人8");
listBoxContacts.Items.Add("联系人9");
listBoxContacts.Items.Add("联系人10");
this.Controls.Add(listBoxContacts);
// 右侧的聊天窗口
Panel panelChat = new Panel();
panelChat.Dock = DockStyle.Fill;
panelChat.Padding = new Padding(10);
panelChat.BackColor = System.Drawing.Color.White;
this.Controls.Add(panelChat);
// 聊天窗口上面的标题
Label lblChatTitle = new Label();
lblChatTitle.Text = "联系人1";
lblChatTitle.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
lblChatTitle.ForeColor = System.Drawing.Color.FromArgb(0, 122, 204);
lblChatTitle.Dock = DockStyle.Top;
lblChatTitle.Padding = new Padding(10);
panelChat.Controls.Add(lblChatTitle);
// 聊天记录
TextBox txtChatRecord = new TextBox();
txtChatRecord.Multiline = true;
txtChatRecord.ReadOnly = true;
txtChatRecord.ScrollBars = ScrollBars.Vertical;
txtChatRecord.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
txtChatRecord.Dock = DockStyle.Top;
txtChatRecord.Height = 500;
txtChatRecord.Text = "这里是聊天记录";
panelChat.Controls.Add(txtChatRecord);
// 发送消息的文本框
TextBox txtSend = new TextBox();
txtSend.Multiline = true;
txtSend.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
txtSend.Dock = DockStyle.Bottom;
txtSend.Height = 100;
panelChat.Controls.Add(txtSend);
// 发送按钮
Button btnSend = new Button();
btnSend.Text = "发送";
btnSend.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
btnSend.ForeColor = System.Drawing.Color.White;
btnSend.FlatStyle = FlatStyle.Flat;
btnSend.BackColor = System.Drawing.Color.FromArgb(0, 122, 204);
btnSend.FlatAppearance.BorderSize = 0;
btnSend.Dock = DockStyle.Right;
btnSend.Width = 100;
btnSend.Height = 50;
btnSend.Click += BtnSend_Click;
panelChat.Controls.Add(btnSend);
}
private void BtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void BtnSend_Click(object sender, EventArgs e)
{
// 发送消息的代码
}
}
}
```
注意:此代码仅为界面演示,不包含任何实际功能。