c# 鼠标在控件上拖动 移动窗体 移动窗口
2024-08-22 02:52:24
#region 移动窗体 移动窗口
private Point _mousePoint;
private int topA(Control cc)
{
if (cc == null || cc == this) return 0;
if (cc.Parent == null || cc.Parent == this)
return cc.Top;
else
return topA(cc.Parent) + cc.Top;
}
private int leftA(Control cc)
{
if (cc == null || cc == this) return 0;
if (cc.Parent == null || cc.Parent == this)
return cc.Left;
else
return leftA(cc.Parent) + cc.Left;
}
private void labTitle_MouseDown(object sender, MouseEventArgs e)
{
Control cc = (Control)sender;
if (e.Button == MouseButtons.Left)
{
_mousePoint.X = e.X + leftA(cc);
_mousePoint.Y = e.Y + topA(cc);
}
}
private void labTitle_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Top = MousePosition.Y - _mousePoint.Y;
Left = MousePosition.X - _mousePoint.X;
}
}
#endregion
最新文章
- LeetCode 206 Reverse a singly linked list.
- SOAPUI使用教程-入门REST测试
- js遍历json
- ViewController的生命周期
- 取消TableViewCell选中状态的外观变化
- 移动端lCalendar纯原生js日期时间选择器
- swift学习笔记-UI篇之UIImageView
- sudo: ./sd_fusing.sh:找不到命令
- 统计 iOS 设备锁定、解锁次数-b
- Android中sharedPreference的简单使用
- The Nerd Factor SPOJ - MYQ5
- MySQL增量订阅&;消费组件Canal POC
- MyBatis Generator 生成器把其他数据库的同名表生成下来的问题
- #include 相关问题
- It is not safe to rely on the system's timezone settings错误
- 【原】Spring AOP实现对Redis的缓存同步
- ftp/sftp定时自动上传文件脚本(CentOS)
- 安全测试6_Web安全工具第一节(浏览器入门及扩展)
- vue + element ui 实现实现动态渲染表格
- 判断RadioButtonList是否选中