System.Windows.Forms Namesp ...


.NET Framework Class Library
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)
Syntax

Visual Basic (Declaration)
Public Class Screen
Visual Basic (Usage)
Dim instance As Screen
C#
public class Screen
Visual C++
public ref class Screen
JScript
public class Screen
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.

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.

Visual Basic
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGetScreenInfo.Click

    Dim Index As Integer
    Dim UpperBound As Integer

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

    Dim Screens() As System.Windows.Forms.Screen = _
        System.Windows.Forms.Screen.AllScreens
    UpperBound = Screens.GetUpperBound(0)

    For Index = 0 To UpperBound

        ' 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())

    Next



End Sub

C#
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());

    }

}
Visual C++
private:
   void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      int index;
      int upperBound;

      // Gets an array of all the screens connected to the system.
      array<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( String::Concat( "Device Name: ", screens[ index ]->DeviceName ) );
         listBox1->Items->Add( String::Concat( "Bounds: ", screens[ index ]->Bounds ) );
         listBox1->Items->Add( String::Concat( "Type: ", screens[ index ]->GetType() ) );
         listBox1->Items->Add( String::Concat( "Working Area: ", screens[ index ]->WorkingArea ) );
         listBox1->Items->Add( String::Concat( "Primary Screen: ", screens[ index ]->Primary ) );
      }
   }
Inheritance Hierarchy

System..::.Object
  System.Windows.Forms..::.Screen
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

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

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0
See Also

Reference

Tags :


Page view tracker