Screen (Clase)
Actualización: noviembre 2007
Representa uno o varios dispositivos de pantalla en un solo sistema.
Ensamblado: System.Windows.Forms (en System.Windows.Forms.dll)
En el ejemplo de código siguiente se muestra cómo se utilizan diversos métodos y propiedades de la clase Screen. El ejemplo llama a la propiedad AllScreens para obtener una matriz de todas las pantallas conectadas al sistema. Para cada objeto Screen devuelto, el ejemplo agrega el nombre del dispositivo, los enlaces, el tipo, el área de trabajo y la pantalla principal a un objeto 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
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile para Smartphone, Windows Mobile para Pocket PC
.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.