Screen.GetWorkingArea 方法   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
检索显示器的工作区。
重载
| GetWorkingArea(Point) | 检索与指定点最接近的工作区。 工作区是显示器的桌面区域,不包括任务栏、停靠窗口和停靠工具栏。 | 
| GetWorkingArea(Rectangle) | 检索包含指定矩形最大部分的显示器的工作区。 工作区是显示器的桌面区域,不包括任务栏、停靠窗口和停靠工具栏。 | 
| GetWorkingArea(Control) | 检索包含指定控件的最大区域的显示器工作区。 工作区是显示器的桌面区域,不包括任务栏、停靠窗口和停靠工具栏。 | 
GetWorkingArea(Point)
检索与指定点最接近的工作区。 工作区是显示器的桌面区域,不包括任务栏、停靠窗口和停靠工具栏。
public:
 static System::Drawing::Rectangle GetWorkingArea(System::Drawing::Point pt);public static System.Drawing.Rectangle GetWorkingArea (System.Drawing.Point pt);static member GetWorkingArea : System.Drawing.Point -> System.Drawing.RectanglePublic Shared Function GetWorkingArea (pt As Point) As Rectangle参数
返回
一个 Rectangle,它指定工作区。 在各显示器都不包含指定点的多显示器环境中,将返回与该点最接近的显示器。
示例
下面的代码示例演示如何使用 PrimaryScreen 属性和 GetWorkingArea 方法。 此方法需要包含名为  按钮的窗体 Button1
   // This method will adjust the size of the form to utilize 
   // the working area of the screen.
private:
   void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      // Retrieve the working rectangle from the Screen class
      // using the PrimaryScreen and the WorkingArea properties.
      System::Drawing::Rectangle workingRectangle = Screen::PrimaryScreen->WorkingArea;
      
      // Set the size of the form slightly less than size of 
      // working rectangle.
      this->Size = System::Drawing::Size( workingRectangle.Width - 10, workingRectangle.Height - 10 );
      
      // Set the location so the entire form is visible.
      this->Location = System::Drawing::Point( 5, 5 );
   }
// This method will adjust the size of the form to utilize 
// the working area of the screen.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
    // Retrieve the working rectangle from the Screen class
    // using the PrimaryScreen and the WorkingArea properties.
    System.Drawing.Rectangle workingRectangle = 
        Screen.PrimaryScreen.WorkingArea;
    
    // Set the size of the form slightly less than size of 
    // working rectangle.
    this.Size = new System.Drawing.Size(
        workingRectangle.Width-10, workingRectangle.Height-10);
    // Set the location so the entire form is visible.
    this.Location = new System.Drawing.Point(5, 5);
}
' This method will adjust the size of the form to utilize 
' the working area of the screen.
Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    ' Retrieve the working rectangle from the Screen class
    ' using the PrimaryScreen and the WorkingArea properties. 
    Dim workingRectangle As System.Drawing.Rectangle = _
        Screen.PrimaryScreen.WorkingArea
    ' Set the size of the form slightly less than size of 
    ' working rectangle.
    Me.Size = New System.Drawing.Size(workingRectangle.Width - 10, _
        workingRectangle.Height - 10)
    ' Set the location so the entire form is visible.
    Me.Location = New System.Drawing.Point(5, 5)
End Sub
适用于
GetWorkingArea(Rectangle)
检索包含指定矩形最大部分的显示器的工作区。 工作区是显示器的桌面区域,不包括任务栏、停靠窗口和停靠工具栏。
public:
 static System::Drawing::Rectangle GetWorkingArea(System::Drawing::Rectangle rect);public static System.Drawing.Rectangle GetWorkingArea (System.Drawing.Rectangle rect);static member GetWorkingArea : System.Drawing.Rectangle -> System.Drawing.RectanglePublic Shared Function GetWorkingArea (rect As Rectangle) As Rectangle参数
返回
一个 Rectangle,它指定工作区。 在各显示器都不包含指定矩形的多显示器环境中,将返回与该矩形最接近的显示器。
适用于
GetWorkingArea(Control)
检索包含指定控件的最大区域的显示器工作区。 工作区是显示器的桌面区域,不包括任务栏、停靠窗口和停靠工具栏。
public:
 static System::Drawing::Rectangle GetWorkingArea(System::Windows::Forms::Control ^ ctl);public static System.Drawing.Rectangle GetWorkingArea (System.Windows.Forms.Control ctl);static member GetWorkingArea : System.Windows.Forms.Control -> System.Drawing.RectanglePublic Shared Function GetWorkingArea (ctl As Control) As Rectangle参数
返回
一个 Rectangle,它指定工作区。 在各显示器都不包含指定控件的多显示器环境中,将返回与该控件最接近的显示器。