Export (0) Print
Expand All

Screen Class

Represents a display device or multiple display devices on a single system.

System.Object
  System.Windows.Forms.Screen

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public class Screen

The Screen type exposes the following members.

  NameDescription
Public propertyStatic memberAllScreensGets an array of all displays on the system.
Public propertyBitsPerPixelGets the number of bits of memory, associated with one pixel of data.
Public propertyBoundsGets the bounds of the display.
Public propertyDeviceNameGets the device name associated with a display.
Public propertyPrimaryGets a value indicating whether a particular display is the primary device.
Public propertyStatic memberPrimaryScreenGets the primary display.
Public propertyWorkingAreaGets the working area of the display. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.
Top

  NameDescription
Public methodEqualsGets or sets a value indicating whether the specified object is equal to this Screen. (Overrides Object.Equals(Object).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodStatic memberFromControlRetrieves a Screen for the display that contains the largest portion of the specified control.
Public methodStatic memberFromHandleRetrieves a Screen for the display that contains the largest portion of the object referred to by the specified handle.
Public methodStatic memberFromPointRetrieves a Screen for the display that contains the specified point.
Public methodStatic memberFromRectangleRetrieves a Screen for the display that contains the largest portion of the rectangle.
Public methodStatic memberGetBounds(Control)Retrieves the bounds of the display that contains the largest portion of the specified control.
Public methodStatic memberGetBounds(Point)Retrieves the bounds of the display that contains the specified point.
Public methodStatic memberGetBounds(Rectangle)Retrieves the bounds of the display that contains the largest portion of the specified rectangle.
Public methodGetHashCodeComputes and retrieves a hash code for an object. (Overrides Object.GetHashCode().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberGetWorkingArea(Control)Retrieves the working area for the display that contains the largest region of the specified control. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.
Public methodStatic memberGetWorkingArea(Point)Retrieves the working area closest to the specified point. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.
Public methodStatic memberGetWorkingArea(Rectangle)Retrieves the working area for the display that contains the largest portion of the specified rectangle. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringRetrieves a string representing this object. (Overrides Object.ToString().)
Top

The constructor for this object is not public, so you cannot explicitly create a Screen object. The object is created when you call its public methods.

The following code example shows how to use various methods and properties of the Screen class. The example calls the AllScreens property to retrieve an array of all the screens connected to the system. For each returned Screen, the example adds the device name, bounds, type, working area, and primary screen to a ListBox. To use the example, add a ListBox and a Button to a form, and then add a Click event handler for the button.

private void button1_Click(object sender, System.EventArgs e)
{
    // For each screen, add the screen properties to a list box. 
    foreach (var screen in System.Windows.Forms.Screen.AllScreens)
    {
        listBox1.Items.Add("Device Name: " + screen.DeviceName);
        listBox1.Items.Add("Bounds: " + 
            screen.Bounds.ToString());
        listBox1.Items.Add("Type: " + 
            screen.GetType().ToString());
        listBox1.Items.Add("Working Area: " + 
            screen.WorkingArea.ToString());
        listBox1.Items.Add("Primary Screen: " + 
            screen.Primary.ToString());
    }

}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft