Editare

Partajați prin


Screen Class

Definition

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

public ref class Screen
public class Screen
type Screen = class
Public Class Screen
Inheritance
Screen

Examples

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.
        for each (Screen^ screen in Screen::AllScreens) {
            listBox1->Items->Add( 
                String::Concat("Device Name: ", screen->DeviceName));
            listBox1->Items->Add( 
                String::Concat("Bounds: ", screen->Bounds));
            listBox1->Items->Add( 
                String::Concat("Type: ", screen->GetType()));
            listBox1->Items->Add( 
                String::Concat("Working Area: ", screen->WorkingArea));
            listBox1->Items->Add( 
                String::Concat("Primary Screen: ", screen->Primary));
        }
    }
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());
    }
}
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ' For each screen, add the screen properties to a list box.
    For Each screen In System.Windows.Forms.Screen.AllScreens
        With ListBox1.Items
            .Add("Device Name: " + screen.DeviceName)
            .Add("Bounds: " + screen.Bounds.ToString())
            .Add("Type: " + screen.GetType().ToString())
            .Add("Working Area: " + screen.WorkingArea.ToString())
            .Add("Primary Screen: " + screen.Primary.ToString())
        End With
    Next
End Sub

Remarks

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.

Properties

AllScreens

Gets an array of all displays on the system.

BitsPerPixel

Gets the number of bits of memory, associated with one pixel of data.

Bounds

Gets the bounds of the display.

DeviceName

Gets the device name associated with a display.

Primary

Gets a value indicating whether a particular display is the primary device.

PrimaryScreen

Gets the primary display.

WorkingArea

Gets the working area of the display. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

Methods

Equals(Object)

Gets or sets a value indicating whether the specified object is equal to this Screen.

FromControl(Control)

Retrieves a Screen for the display that contains the largest portion of the specified control.

FromHandle(IntPtr)

Retrieves a Screen for the display that contains the largest portion of the object referred to by the specified handle.

FromPoint(Point)

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

FromRectangle(Rectangle)

Retrieves a Screen for the display that contains the largest portion of the rectangle.

GetBounds(Control)

Retrieves the bounds of the display that contains the largest portion of the specified control.

GetBounds(Point)

Retrieves the bounds of the display that contains the specified point.

GetBounds(Rectangle)

Retrieves the bounds of the display that contains the largest portion of the specified rectangle.

GetHashCode()

Computes and retrieves a hash code for an object.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
GetWorkingArea(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.

GetWorkingArea(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.

GetWorkingArea(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.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Retrieves a string representing this object.

Applies to