Screen.FromPoint(Point) メソッド

定義

指定したポイントを保持するディスプレイを表す 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

パラメーター

point
Point

Point の取得条件となる位置を指定する Screen

戻り値

ポイントを保持するディスプレイを表す Screen。 ポイントを保持するディスプレイがない複数ディスプレイ環境では、指定したポイントに最も近いディスプレイが返されます。

FromPoint メソッドを使用するコード例を次に示します。 次の使用例は、 によって渡された MouseEventArgsY 座標を参照Xする を作成Pointし、 メソッドを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

適用対象

こちらもご覧ください