[英]The Difference Between MousEventArgs.Location and Cursor.Position
I don't understand why Cursor.Position is different from MouseEventArgs.Location , they should be the same, don't they? 我不明白为什么Cursor.Position与MouseEventArgs.Location不同,它们应该是一样的,不是吗?
Edit: The answer seems to suggest that Cursor.Position== PointToScreen(MouseEventArgs.Location)
, but my testing indicates otherwise. 编辑:答案似乎建议
Cursor.Position== PointToScreen(MouseEventArgs.Location)
,但我的测试表明不然。
MouseEventArgs.Position is the mouse cursor position relative to the control during the event , at the time of the event . MouseEventArgs.Position是相对的鼠标光标的位置到控制活动期间 , 在事件发生的时间 。
Cursor.Position is the current mouse cursor position relative to the desktop . Cursor.Position是相对于桌面的当前鼠标光标位置。
MouseEventArgs.location gives you the cursor position relative to the control during the event . MouseEventArgs.location为您提供事件期间相对于控件的光标位置。
Windows.Forms.Cursor.Position gives you the cursor position relative to the desktop. Windows.Forms.Cursor.Position为您提供相对于桌面的光标位置。
Obviously, these two need not be and are not same. 显然,这两者不一定也不相同。 The latter can be used without an event as such too unlike MouseEventArgs.Location
后者可以在没有事件的情况下使用,因为它与MouseEventArgs.Location不同
我认为Cursor.Position是相对于桌面的,而MouseEventArgs.Location是相对于触发事件的控件
MouseEventArgs.Position是相对于控件的客户端矩形 ,Cursor.Position是屏幕坐标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.