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; namespace WinGPChat.master { public partial class formBase : Form { public formBase() { InitializeComponent(); } private Point mPoint = new Point(); private void formBase_Load(object sender, EventArgs e) { this.MouseDown+=formBase_MouseDown; this.MouseMove+=formBase_MouseMove; } protected void formBase_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { Point myPosittion = MousePosition; myPosittion.Offset(-mPoint.X, -mPoint.Y); this.FindForm().Location = myPosittion; } } protected void formBase_MouseDown(object sender, MouseEventArgs e) { mPoint.X = e.X; mPoint.Y = e.Y; } /// <summary> /// 重写Paint实现细边框 /// </summary> /// <param name="e"></param> protected override void OnPaint(PaintEventArgs e) { Pen pen = ); e.Graphics.DrawLine(pen, , ), , )); //上 e.Graphics.DrawLine(pen, , ), , )); //左 e.Graphics.DrawLine(pen, , ), , ));//右 e.Graphics.DrawLine(pen, , ), , ));//下 base.OnPaint(e); } /// <summary> /// 无边框重写点击icon实现窗体最大化和最小化 /// </summary> protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.Style = cp.Style | 0x20000;//允许最小化操作 return cp; } } } }