获取鼠标点击DoubleClick事件的位置/按钮 [英] Obtain Position/Button of mouse click on DoubleClick event

查看:283
本文介绍了获取鼠标点击DoubleClick事件的位置/按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来获得(X,Y)坐标中的鼠标光标的控制DoubleClick事件?

Is there a method to obtain the (x, y) coordinates of the mouse cursor in a controls DoubleClick event?

据我所知道的,位置必须从全球获得的:

As far as I can tell, the position has to be obtained from the global:


Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y

此外,有没有一种方法以获得按钮产生的双击?

Also, is there a method to obtain which button produced the double click?

推荐答案

Control.MousePosition和Control.MouseButtons是你所期待的。使用Control.PointToClient()和Control.PointToScreen()屏幕之间的相对坐标转换控制。

Control.MousePosition and Control.MouseButtons is what you are looking for. Use Control.PointToClient() and Control.PointToScreen() to convert between screen and control relative coordinates.

请参阅MSDN Control.MouseButtons地产 Control.MousePosition物业 Control.PointToClient方法 Control.PointToScreen方法了解详细信息。

See MSDN Control.MouseButtons Property, Control.MousePosition Property, Control.PointToClient Method, and Control.PointToScreen Method for details.

更新

不见树木,不见森林...:D见驼鹿的的答案,看看事件参数。

Not to see the wood for the trees... :D See Moose's answer and have a look at the event arguments.

MSDN文章名单该鼠标操作触发取决于控制哪些事件

This MSDN article lists which mouse actions trigger which events depending on the control.

更新

我错过了驼鹿的演员所以这是行不通的。你必须从内部Control.DoubleClick()使用静态控制性能。因为按钮的信息是连接codeD作为位域yoou要测试您想要使用的按钮如下:

I missed Moose's cast so this will not work. You have to use the static Control properties from inside Control.DoubleClick(). Because the button information is encoded as bit field yoou have to test as follows using your desired button.

(Control.MouseButtons & MouseButtons.Left) == MouseButtons.Left

这篇关于获取鼠标点击DoubleClick事件的位置/按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆