WPF 与winform获取鼠标坐标的差异
来源:互联网 发布:淘宝卖东西进货渠道 编辑:程序博客网 时间:2024/06/05 12:55
winform中以Panel为例的MouseDown事件为:
private void panelposition_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
//分别用e.X,e.Y来获取鼠标的x,y坐标(e.X,e.Y分别为整数)
int x=e.X;
int y=e.Y;
}
{
//分别用e.X,e.Y来获取鼠标的x,y坐标(e.X,e.Y分别为整数)
int x=e.X;
int y=e.Y;
}
wpf中以Image为例的MouseDown事件为:
private void imageposition_MouseDown(object sender, MouseButtonEventArgs e)
{
//采用e.GetPosition(IInputElement relativeTo)来获取鼠标的x,y坐标
//以下部分来自于metadata中:
//--------------------------------------------------------------
// Summary:
// Returns the position of the mouse pointer relative to the specified element.
//
// Parameters:
// relativeTo:
// The element to use as the frame of reference for calculating the position
// of the mouse pointer.
//
// Returns:
// The x- and y-coordinates of the mouse pointer position relative to the specified
// object.
public Point GetPosition(IInputElement relativeTo);
//--------------------------------------------------------------
//其中relativeTo为选择的对象,即在图片上面就是图片对象,窗体上面就是window对象。
//e.GetPosition(img).X为double类型,需转换后使用。
int x = Convert.ToInt32(e.GetPosition(img).X);
int y = Convert.ToInt32(e.GetPosition(img).Y);
}
{
//采用e.GetPosition(IInputElement relativeTo)来获取鼠标的x,y坐标
//以下部分来自于metadata中:
//--------------------------------------------------------------
// Summary:
// Returns the position of the mouse pointer relative to the specified element.
//
// Parameters:
// relativeTo:
// The element to use as the frame of reference for calculating the position
// of the mouse pointer.
//
// Returns:
// The x- and y-coordinates of the mouse pointer position relative to the specified
// object.
public Point GetPosition(IInputElement relativeTo);
//--------------------------------------------------------------
//其中relativeTo为选择的对象,即在图片上面就是图片对象,窗体上面就是window对象。
//e.GetPosition(img).X为double类型,需转换后使用。
int x = Convert.ToInt32(e.GetPosition(img).X);
int y = Convert.ToInt32(e.GetPosition(img).Y);
}
本文来自娜老汉的博客,原文地址:http://www.cnblogs.com/peasana/archive/2012/02/13/2349523.html
- WPF 与winform获取鼠标坐标的差异
- WPF中如何获取鼠标相对于桌面的坐标
- winform 获得鼠标的坐标
- 获取鼠标的坐标
- 获取鼠标的坐标
- 获取鼠标的坐标
- WinForm和WPF控件的差异
- 浏览器的鼠标坐标值获取及pageX、clientX、screenX的差异
- Jquery 获取鼠标的坐标
- JS获取鼠标的坐标
- 获取当前鼠标的坐标
- JS获取鼠标的坐标
- C#获取鼠标的坐标
- 随鼠标获取鼠标的坐标代码
- winform 获取鼠标的位置
- WPF获取鼠标的位置
- winform Chart控件 获取鼠标处坐标值方法
- 通过SPY++实测WinForm和WPF控件的差异
- 32位程序移植到64位平台前的准备工作
- C语言 - ACM题目:平均绩点
- Halcon学习之六:获取Image图像中Region区域的特征参数
- 关于sort()的使用的一些描述
- iOS中Button控件的学习
- WPF 与winform获取鼠标坐标的差异
- 【cocos2d-x IOS游戏开发-城市跑酷8】实现街区房子的摆放
- 软件架构设计箴言
- hdu-2501-Bitset
- Halcon学习之五:有关图像的定义域的函数
- 64位系统下,一个32位的程序究竟可以申请到多少内存,4GB还是更多?
- Silverlight API坐标点生成线并量测标注
- Halcon学习之七:改变图像的现实方式和大小
- LeetCode 3Sum Closest