This documentation is archived and is not being maintained.

Screen.FromPoint Method

Retrieves a Screen for the display that contains the specified point.

[Visual Basic]
Public Shared Function FromPoint( _
   ByVal point As Point _
) As Screen
public static Screen FromPoint(
 Point point
public: static Screen* FromPoint(
 Point point
public static function FromPoint(
   point : Point
) : Screen;


A Point that specifies the location for which to retrieve a Screen.

Return Value

A Screen for the display that contains the point. In multiple display environments where no display contains the point, the display closest to the specified point is returned.


[Visual Basic, C#, C++] The following example shows how to use the FromPoint method. This example creates a Point referencing the X and Y coordinates passed by a MouseEventArgs, and then uses the FromPoint method to determine if the point clicked is on the primary screen.

[Visual Basic] 
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")
        MessageBox.Show("This isn't the primary screen")
    End If
End Sub

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");
    MessageBox.Show("This isn't the primary screen");

    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(S"You clicked the primary screen");
        } else {
            MessageBox::Show(S"This isn't the primary screen");

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Screen Class | Screen Members | System.Windows.Forms Namespace | FromControl | FromHandle | FromRectangle