c# 鼠标在控件上拖动 移动窗体 移动窗口
#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
c# 鼠标在控件上拖动 移动窗体 移动窗口的更多相关文章
- (转)C# WinForm中 获得当前鼠标所在控件 或 将窗体中鼠标所在控件名显示在窗体标题上
原文地址:http://www.cnblogs.com/08shiyan/archive/2011/04/14/2015758.html /********************** * 课题:将窗 ...
- Qt判断鼠标在控件上
QT判断鼠标是否在某子窗口控件上方 需要注意的是,子窗口获取geometry,是相对于父窗口的相对位置,QCursor::pos()获取的是鼠标绝对位置,要不将父窗口的相对位置进行换算,要不将鼠标的绝 ...
- C#如何在panl控件上添加Form窗体
. if (treeView1.SelectedNode.Text == "个人信息") { Form1 f4 = new Form1(); f4.TopLevel = false ...
- 在WPF中的Canvas上实现控件的拖动、缩放
如题,项目中需要实现使用鼠标拖动.缩放一个矩形框,WPF中没有现成的,那就自己造一个轮子:) 造轮子前先看看Windows自带的画图工具中是怎样做的,如下图: 在被拖动的矩形框四周有9个小框,可以从不 ...
- Unity编辑器 - 鼠标悬停在控件上时改变鼠标样式
Unity编辑器 - 鼠标悬停在控件上时改变鼠标样式 摘自Unity文档 EditorGUIUtility.AddCursorRect public static void AddCursorRect ...
- c# 鼠标点击控件即拖动窗体
在编程中,有时打开的窗体没有边框,但是我们仍然想在鼠标放在窗体上就能拖动窗体,这样我们只需要以窗体中的一个控件为参考,我们在这里以panel为例子: public class PanelNew : P ...
- C#中,当鼠标移动到控件上,动态显示提示内容 ToolTip
[背景]写了个C#的小程序,其中在Settings窗体中有些配置参数,希望在鼠标移动到对应的配置选项上,动态显示相关的说明解释内容. [解决过程]1.原先就已经知道,有些控件,是带ToolTipTex ...
- VC/MFC 当鼠标移到控件上时显示提示信息
VC/MFC 当鼠标移到控件上时显示提示信息 ToolTip是Win32中一个通用控件,MFC中为其生成了一个类CToolTipCtrl,总的说来其使用方法是较简单的,下面讲一下它的一般用法和高级用法 ...
- 如何获得 Qt窗口部件在主窗口中的位置--确定鼠标是否在某一控件上与在控件上的位置
用Qt Creator 设计程序时,最方便的就是ui设计器,可以很容易的得到想要的布局. 但是这样自动布局带来的后果是很难知道窗口中某一部件在主窗口中的相对位置. 在处理子窗口鼠标事件时变的很麻烦.主 ...
随机推荐
- 阅读<构建之法>第三10、11、12章
第10章:典型用户和场景 阅读了第10章之后,我知道典型用户很重要,典型用户是某类群体的代表,他们的观点能够反映一类人的观点与对产品的要求,那么要怎么样才能够从一类群体里,选择正确的典型用户反映我们研 ...
- Word embedding blog
http://colah.github.io/posts/2014-07-NLP-RNNs-Representations/ https://www.quora.com/What-is-the-def ...
- 常见的XMLHttpRequest.status状态码
XMLHttpRequest.status状态码 1xx-信息提示 这些状态代码表示临时的响应.客户端在收到常规响应之前,应准备接收一个或多个1xx响应. 100-继续. 101-切换协议. 2xx- ...
- Spark读取HDFS文件,文件格式为GB2312,转换为UTF-8
package iie.udps.example.operator.spark; import scala.Tuple2; import org.apache.hadoop.conf.Configur ...
- Xen虚拟机磁盘镜像模板制作(一)—Windows Server 2008(2012)
这段时间一直在研究如何制作一个适合Xen虚拟化的Windows Server 2008(2012)磁盘镜像,中间虽然遇到了一些阻挠,不过最终还是顺利解决,成功制作出了Xen Windows Serve ...
- UVa 10810 - Ultra-QuickSort
题目大意:给出一个数列,每次交换相邻数字,求排成递增序的最少交换次数. 分析:求逆序数,合并排序 #include<cstdio>#include<cstring>#inclu ...
- ZOJ 3805--解题报告
题目相关: 3805相关链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5337 在二维的矩形上, 机器通过管道(pipe ...
- web项目中各种路径的获取HttpServletRequest
以工程名为/DemoWeb为例: 访问的jsp为:http://localhost:8080/DemoWeb/test/index.jsp 1 JSP中获得当前应用的相对路径和绝对路径 (1)得到工程 ...
- 创建kafkatopic和productor
cd 到kafka 目录下 创建topic create topicbin/kafka-topics.sh --zookeeper spark1:2181,spark2:2181,spark3:218 ...
- POJ 2186 Popular Cows(强连通)
Popular Cows Time Limit: 2000MS Memo ...