在屏幕上找到坐标点? [英] Find Coordinates for point on screen?

查看:112
本文介绍了在屏幕上找到坐标点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是我以表格形式显示了一些图形,例如矩形,并且当点超过thees字段时我想捕获.因此,我尝试找到这些矩形的corrrdinates,但由于坐标是形式,因此与鼠标位置不匹配.

The thing is I have some graphics shown in a form, rectangle for example, and I want to capture when the point gets over thees fields. So I Thoght I try to find the corrrdinates for thees rectangles, but as thay are the coords in the form it dose not match the ones with the mouse location.

所以我想知道是否有一种方法可以找到Point在屏幕上而不是在窗体或控制器中在屏幕上的坐标?

So I wonder is there a way to find what coord on the screen a Point has on the screen and not in the form or controller?

推荐答案

每个控件都有用于转换的PointToFoo方法.请注意,您应该从所需位置的对象的父对象处调用它:

Each control hs PointToFoo methods for conversion. Note that you should call this from the parent of the object who's location you want:

Point scrPos = this.PointToScreen(panel1.Location);

或者,您可以使用以下方法获取面板的屏幕坐标:

Alternatively, you can get the panel's screen coordinates with:

Point scrPos = panel1.PointToScreen(new Point(0,0));

请注意,由于面板的边框大小,以上两个示例可能会得出不同的结果.

Note that the above two examples could gve different result due to the border-size of the panel.

这篇关于在屏幕上找到坐标点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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