Export (0) Print
Expand All
15 out of 16 rated this helpful - Rate this topic

Screen Class

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

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public class Screen
public class Screen
public class Screen
Not applicable.

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.


private void button1_Click(object sender, System.EventArgs e)
{
	int index;
	int upperBound; 

	// Gets an array of all the screens connected to the system.

	Screen [] screens = Screen.AllScreens;
	upperBound = screens.GetUpperBound(0);

	for(index = 0; index <= upperBound; index++)
	{

		// For each screen, add the screen properties to a list box.

		listBox1.Items.Add("Device Name: " + screens[index].DeviceName);
		listBox1.Items.Add("Bounds: " + screens[index].Bounds.ToString());
		listBox1.Items.Add("Type: " + screens[index].GetType().ToString());
		listBox1.Items.Add("Working Area: " + screens[index].WorkingArea.ToString());
		listBox1.Items.Add("Primary Screen: " + screens[index].Primary.ToString());

	}

}

private void button1_Click(Object sender, System.EventArgs e)
{
    int index;
    int upperBound;
    // Gets an array of all the screens connected to the system.
    Screen screens[] = Screen.get_AllScreens();
    upperBound = screens.GetUpperBound(0);

    for (index = 0; index <= upperBound; index++) {
        // For each screen, add the screen properties to a list box.
        listBox1.get_Items().Add("Device Name: " + screens[index].
            get_DeviceName());
        listBox1.get_Items().Add("Bounds: " + screens[index].get_Bounds()
            .ToString());
        listBox1.get_Items().Add("Type: " + screens[index].GetType().
            ToString());
        listBox1.get_Items().Add("Working Area: " + screens[index].
            get_WorkingArea().ToString());
        listBox1.get_Items().Add("Primary Screen: " + 
            ((System.Boolean)screens[index].get_Primary()).ToString());
    }
} //button1_Click

System.Object
  System.Windows.Forms.Screen
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.