获取鼠标在表单上的位置的最佳方法是什么?

发布于 2024-07-20 06:12:43 字数 138 浏览 8 评论 0原文

我想要获取表单鼠标位置的最佳方法。

我现在在变量中设置鼠标位置的值,以便在另一种方法“如 Form1_Click”中获取它们。

有没有更好的方法可以做到这一点?

非常感谢。

I want the best way to get mouse position for Form.

I,m now set the values of mouse position in variables to get them in another methods "Like Form1_Click".

Is there any better way to do that??.

Thank you very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

听风念你 2024-07-27 06:12:43
xm=System.Windows.Forms.Cursor.Position.X - this.Location.X
ym=System.Windows.Forms.Cursor.Position.Y - this.Location.Y

那么你应该这样做:

xm - form border x 
ym - form border y
xm=System.Windows.Forms.Cursor.Position.X - this.Location.X
ym=System.Windows.Forms.Cursor.Position.Y - this.Location.Y

then you should do:

xm - form border x 
ym - form border y
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文