c# 无边框窗体鼠标点击移动方法
来源:互联网 发布:淘宝宝婴儿秋冬服装 编辑:程序博客网 时间:2024/05/16 08:09
c# 无边框窗体鼠标点击移动两种方法
1.在mouse事件中实现
2.调用windows API
实现方式为:
1.在mouse事件中实现
Point mouseOff;//鼠标移动位置变量 bool leftFlag;//标签是否为左键 private void groupControl1_MouseUp(object sender, MouseEventArgs e) { if (leftFlag) { leftFlag = false;//释放鼠标后标注为false; } } private void groupControl1_MouseMove(object sender, MouseEventArgs e) { if (leftFlag) { Point mouseSet = Control.MousePosition; mouseSet.Offset(mouseOff.X, mouseOff.Y); //设置移动后的位置 Location = mouseSet; } } private void groupControl1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { mouseOff = new Point(-e.X, -e.Y); //得到变量的值 leftFlag = true; //点击左键按下时标注为true; } } private void groupControl1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { mouseOff = new Point(-e.X, -e.Y); //得到变量的值 leftFlag = true; //点击左键按下时标注为true; } }
2.调用windows API
调用前需要添加using System.Runtime.InteropServices;
[DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); private void groupControl1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { ReleaseCapture(); //释放鼠标捕捉 //发送左键点击的消息至该窗体(标题栏) SendMessage(Handle, 0xA1, 0x02, 0); } }
0 0
- c# 无边框窗体鼠标点击移动方法
- C# winform 无边框窗体鼠标点击移动事件
- C# winform 无边框窗体鼠标点击移动事件
- C# form窗体无边框后,鼠标移动窗体
- C# 无边框窗体移动
- C# 移动无边框窗体
- c#移动无边框窗体
- [转]C#无边框窗体移动的三种方法
- [转]C#无边框窗体移动的三种方法
- [转]C#无边框窗体移动的三种方法
- C#移动无边框窗体的简单方法
- C# 无边框窗体 移动 两种方法
- C# 如何鼠标拖动无边框窗体
- C# 用鼠标拖动无边框窗体
- C# 如何鼠标拖动无边框窗体
- C# 无边框窗体的移动
- 使用C#实现移动无边框窗体
- 使用C#实现移动无边框窗体
- 请求转发与重定向
- [LeetCode]136. Single Number&137. Single Number II&260. Single Number III
- 使用libpqxx访问PostgreSQL数据库(mingw编译libpqxx)
- SpringMVC @RequestBody 接收Json数组对象
- TableViewCell的3D翻转特效
- c# 无边框窗体鼠标点击移动方法
- 说说悠百佳加盟品牌的价格骗局
- 博客开始
- C#实现 CAT021报文格式解析
- 学习Javascript闭包(Closure)
- 图像的运算--点运算
- Hashcode的作用
- Wex5 通过ajax访问远程数据
- 按钮在执行frame动画的时候怎么响应触发事件?