Screen.FromPoint(Point) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
检索包含指定点的显示器的 Screen。
public:
static System::Windows::Forms::Screen ^ FromPoint(System::Drawing::Point point);
public static System.Windows.Forms.Screen FromPoint (System.Drawing.Point point);
static member FromPoint : System.Drawing.Point -> System.Windows.Forms.Screen
Public Shared Function FromPoint (point As Point) As Screen
参数
返回
包含该点的显示器的 Screen。 在各显示器都不包含指定点的多显示器环境中,将返回与该点最接近的显示器。
示例
下面的代码示例说明如何使用 FromPoint 方法。 此示例创建一个Point引用 X 由 MouseEventArgs传递的 和 Y 坐标,然后使用 FromPoint 方法确定单击的点是否位于主屏幕上。
private:
void Form1_MouseDown( Object^ /*sender*/, System::Windows::Forms::MouseEventArgs^ e )
{
Point p = Point(e->X,e->Y);
Screen^ s = Screen::FromPoint( p );
if ( s->Primary )
{
MessageBox::Show( "You clicked the primary screen" );
}
else
{
MessageBox::Show( "This isn't the primary screen" );
}
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
Point p = new Point(e.X, e.Y);
Screen s = Screen.FromPoint(p);
if (s.Primary)
{
MessageBox.Show("You clicked the primary screen");
}
else
{
MessageBox.Show("This isn't the primary screen");
}
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
Dim p As New System.Drawing.Point(e.X, e.Y)
Dim s As System.Windows.Forms.Screen = Screen.FromPoint(p)
If s.Primary = True Then
MessageBox.Show("You clicked the primary screen")
Else
MessageBox.Show("This isn't the primary screen")
End If
End Sub