Screen Screen Screen Screen Class

定义

表示单个系统上的一个或多个显示设备。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
继承
ScreenScreenScreenScreen

示例

下面的代码示例演示如何使用Screen类的各种方法和属性。The following code example shows how to use various methods and properties of the Screen class. 该示例调用AllScreens属性以检索连接到系统的所有屏幕的数组。The example calls the AllScreens property to retrieve an array of all the screens connected to the system. 对于每个Screen返回的, 该示例将设备名称、边界、类型、工作区和主屏幕添加ListBox到。For each returned Screen, the example adds the device name, bounds, type, working area, and primary screen to a ListBox. 若要使用此示例, 请ListBoxButton和添加到窗体Click中, 然后为该按钮添加事件处理程序。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

注解

此对象的构造函数不是公共的, 因此不能显式创建Screen对象。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.

属性

AllScreens AllScreens AllScreens AllScreens

获取系统上所有显示器的数组。Gets an array of all displays on the system.

BitsPerPixel BitsPerPixel BitsPerPixel BitsPerPixel

获取与数据的一个像素相关联的内存位数。Gets the number of bits of memory, associated with one pixel of data.

Bounds Bounds Bounds Bounds

获取显示的边界。Gets the bounds of the display.

DeviceName DeviceName DeviceName DeviceName

获取与显示关联的设备名称。Gets the device name associated with a display.

Primary Primary Primary Primary

获取一个值,该值指示某个显示是否为主设备。Gets a value indicating whether a particular display is the primary device.

PrimaryScreen PrimaryScreen PrimaryScreen PrimaryScreen

获取主显示。Gets the primary display.

WorkingArea WorkingArea WorkingArea 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.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

获取或设置一个值,该值指示指定的对象是否等于该 ScreenGets or sets a value indicating whether the specified object is equal to this Screen.

FromControl(Control) FromControl(Control) FromControl(Control) FromControl(Control)

Screen 中检索包含指定控件的最大部分的显示器。Retrieves a Screen for the display that contains the largest portion of the specified control.

FromHandle(IntPtr) FromHandle(IntPtr) FromHandle(IntPtr) FromHandle(IntPtr)

检索包含该对象(被指定句柄所引用)的最大部分的显示器的 ScreenRetrieves a Screen for the display that contains the largest portion of the object referred to by the specified handle.

FromPoint(Point) FromPoint(Point) FromPoint(Point) FromPoint(Point)

检索包含指定点的显示器的 ScreenRetrieves a Screen for the display that contains the specified point.

FromRectangle(Rectangle) FromRectangle(Rectangle) FromRectangle(Rectangle) FromRectangle(Rectangle)

检索包含矩形的最大部分的显示器的 ScreenRetrieves a Screen for the display that contains the largest portion of the rectangle.

GetBounds(Control) GetBounds(Control) GetBounds(Control) GetBounds(Control)

检索包含指定控件的最大部分的显示器的边界。Retrieves the bounds of the display that contains the largest portion of the specified control.

GetBounds(Point) GetBounds(Point) GetBounds(Point) GetBounds(Point)

检索包含指定点的显示器的边界。Retrieves the bounds of the display that contains the specified point.

GetBounds(Rectangle) GetBounds(Rectangle) GetBounds(Rectangle) GetBounds(Rectangle)

检索包含指定矩形最大部分的显示器的边界。Retrieves the bounds of the display that contains the largest portion of the specified rectangle.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

计算并检索对象的哈希代码。Computes and retrieves a hash code for an object.

GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
GetWorkingArea(Control) GetWorkingArea(Control) GetWorkingArea(Control) 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) GetWorkingArea(Point) GetWorkingArea(Point) 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) GetWorkingArea(Rectangle) GetWorkingArea(Rectangle) 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() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

检索表示此对象的字符串。Retrieves a string representing this object.

适用于