Screen.FromPoint(Point) Método

Definición

Recupera un Screen para la presentación que contiene el punto especificado.

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

Parámetros

point
Point

que Point especifica la ubicación para la que se va a recuperar un Screenobjeto .

Devoluciones

para Screen la pantalla que contiene el punto. En varios entornos de presentación en los que ninguna presentación contiene el punto, se devuelve la pantalla más cercana al punto especificado.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el FromPoint método . En este ejemplo se crea una Point referencia a las X coordenadas y Y pasadas por MouseEventArgsy, a continuación, se usa el FromPoint método para determinar si el punto en el que se hace clic está en la pantalla 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

Se aplica a

Consulte también