博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Winform 无边框窗口移动自定义边框粗细颜色
阅读量:6738 次
发布时间:2019-06-25

本文共 2251 字,大约阅读时间需要 7 分钟。

1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms;10 11 namespace WinGPChat.master12 {13     public partial class formBase : Form14     {15         public formBase()16         {17             InitializeComponent();            18         }19         private Point mPoint = new Point();20         private void formBase_Load(object sender, EventArgs e)21         {22             this.MouseDown+=formBase_MouseDown;23             this.MouseMove+=formBase_MouseMove;            24         }25 26         protected void formBase_MouseMove(object sender, MouseEventArgs e)27         {28             if (e.Button == MouseButtons.Left)29             {30                 Point myPosittion = MousePosition;31                 myPosittion.Offset(-mPoint.X, -mPoint.Y);32                 this.FindForm().Location = myPosittion;33             }34         }35 36         protected void formBase_MouseDown(object sender, MouseEventArgs e)37         {38             mPoint.X = e.X;39             mPoint.Y = e.Y;40         }41 42         /// 43         /// 重写Paint实现细边框44         /// 45         /// 46         protected override void OnPaint(PaintEventArgs e)47         {48             Pen pen = new Pen(Color.Gray,1);49             e.Graphics.DrawLine(pen, new Point(0, 0), new Point(this.Width-1, 0));   //上50             e.Graphics.DrawLine(pen, new Point(0, 0), new Point(0, this.Height-1));  //左51             e.Graphics.DrawLine(pen, new Point(this.Width-1, 0), new Point(this.Width-1, this.Height-1));//右52             e.Graphics.DrawLine(pen, new Point(0, this.Height-1), new Point(this.Width-1, this.Height-1));//下53             base.OnPaint(e);54         }55 56         /// 57         /// 无边框重写点击icon实现窗体最大化和最小化58         /// 59         protected override CreateParams CreateParams60         {61             get62             {63                 CreateParams cp = base.CreateParams;64                 cp.Style = cp.Style | 0x20000;//允许最小化操作65                 return cp;66             }67         }68 69            70     }71 }

 

转载于:https://www.cnblogs.com/jieliu726/p/4674360.html

你可能感兴趣的文章
【Spark Summit East 2017】不必犹豫,使用Spark 2.0结构化流
查看>>
HTTPFS: 基于HTTP操作hadoop hdfs文件系统
查看>>
使用jquery获取父元素或父节点的方法
查看>>
如何让双十一数据大屏讲出故事?设计有口诀
查看>>
浮窗系列之窗口与用户输入系统
查看>>
swing效果点击下拉框自动填充文本框
查看>>
UML之活动图
查看>>
[收藏学习]安全性相关
查看>>
测来测去,感觉REQUESTS最实在
查看>>
powershell 模拟IE行为
查看>>
细说ES7 JavaScript Decorators
查看>>
最好的团队
查看>>
Objective-C之@类别小实例
查看>>
IOS的唯一标识符问题(转)
查看>>
【Oracle】How to Rename or Move Datafiles and Logfiles 之一
查看>>
CYQ.Data 轻量数据访问层(六) 构造数据表
查看>>
CFRunLoop
查看>>
一次XEN虚拟化安装虚机系统时的换光盘操作
查看>>
第五天 应用代理SQUID
查看>>
CDH使用之CM、CDH4、5卸载
查看>>