Screen.FromPoint(Point) Méthode

Définition

Récupère Screen pour l'affichage qui contient le point spécifié.

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

Paramètres

point
Point

Point qui spécifie l'emplacement pour lequel Screen doit être récupéré.

Retours

Screen

Screen pour l'affichage qui contient le point. Dans plusieurs environnements d'affichage où aucun affichage ne contient le point, l'affichage le plus proche du point spécifié est retourné.

Exemples

L'exemple de code suivant montre comment utiliser la méthode FromPoint. Cet exemple crée un Point référencement des X coordonnées Y passées par un MouseEventArgs, puis utilise la FromPoint méthode pour déterminer si le point cliqué est sur l’écran principal.

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

S’applique à

Voir aussi