开发者

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?

Edit: The answer seems to suggest that Cursor.Position== PointToScreen(MouseEventArgs.Location), but my testing indic开发者_开发百科ates otherwise.


MouseEventArgs.Position is the mouse cursor position relative to the control during the event, at the time of the event.

Cursor.Position is the current mouse cursor position relative to the desktop.


MouseEventArgs.location gives you the cursor position relative to the control during the event.

Windows.Forms.Cursor.Position gives you the cursor position relative to the desktop.

Obviously, these two need not be and are not same. The latter can be used without an event as such too unlike MouseEventArgs.Location


I think Cursor.Position is relative to the desktop, whereas MouseEventArgs.Location is relative to the control that fired the event


MouseEventArgs.Position is relative to the client rectangle of the control, Cursor.Position is in screen coordinate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜