c# 模拟windows桌面鼠标拖选 张宇轩
来源:互联网 发布:鸿鹄安知燕雀之志王侯 编辑:程序博客网 时间:2024/04/29 23:24
命名空间
using System.Drawing;
定义两个变量
bool MouseIsDown=false;
Rectangle MouseRect = Rectangle.Empty;
定义三个方法
private void ResizeToRectangle(Point p)
{
DrawRectangle();
MouseRect.Width = p.X - MouseRect.Left;
MouseRect.Height = p.Y - MouseRect.Top;
DrawRectangle();
}
private void DrawRectangle()
{
Rectangle rect = this.RectangleToScreen(MouseRect);
ControlPaint.DrawReversibleFrame(rect,Color.White,FrameStyle.Dashed);
}
private void DrawStart(Point StartPoint)
{
this.Capture = true;
Cursor.Clip = this.RectangleToScreen(this.Bounds);
MouseRect = new Rectangle(StartPoint.X,StartPoint.Y,0,0);
}
在鼠标按下事件里写(一定是鼠标按下事件MouseDown 因为我的参数e是鼠标数据对象
(不过你也可以传坐标))
MouseIsDown = true;
DrawStart(e.Location);
在鼠标移动(MouseMove)事件里写
if(MouseIsDown)
ResizeToRectangle(e.Location);
在鼠标释放(MouseUp)事件里写
this.Capture = false;
Cursor.Clip = Rectangle.Empty;
MouseIsDown = false;
DrawRectangle();
MouseRect = Rectangle.Empty;
- c# 模拟windows桌面鼠标拖选 张宇轩
- 模拟鼠标桌面点击(桌面机器人)
- C# 模拟鼠标操作
- C#模拟鼠标
- C#模拟鼠标
- C# 模拟鼠标事件
- C# 键盘鼠标模拟
- C#模拟鼠标,键盘
- C#模拟鼠标,键盘 .
- c# 模拟鼠标移动
- C# 模拟鼠标事件
- C# 模拟鼠标写字
- c# 模拟鼠标点击
- C#模拟鼠标操作
- Ext JS模拟Windows桌面
- windows 模拟按键与鼠标
- c#模拟鼠标键盘操作
- C#模拟键盘鼠标事件
- struts2 控制标签
- eVC下CString 操作指南 转自http://blog.csdn.net/favory/archive/2008/11/05/3227606.aspx
- WATMServer 安装中的注意事项
- Again, Notes on Alignment
- 提高ASP.NET性能的几点
- c# 模拟windows桌面鼠标拖选 张宇轩
- windows空密码无法直接登录
- 警惕JavaScript的对象属性无法自动求值的陷阱
- C# 实现图片旋转的代码 张宇轩
- 模板类(Map和set)- -
- ping
- None
- c++vector模板类
- c++vector模板类