Screen.FromPoint(Point) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Recupera un oggetto Screen per la visualizzazione che contiene il punto specificato.
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
Parametri
Valori restituiti
Oggetto Screen per la visualizzazione che contiene il punto. In più ambienti di visualizzazione in cui nessuna visualizzazione contiene il punto, viene restituito lo schermo più vicino al punto specificato.
Esempio
Nell'esempio di codice seguente viene illustrato come usare il FromPoint metodo . In questo esempio viene creato un Point riferimento alle X coordinate e Y passate da un MouseEventArgsoggetto e quindi viene utilizzato il FromPoint metodo per determinare se il punto selezionato si trova sullo schermo primario.
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