Screen.GetWorkingArea 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
检索显示器的工作区。
重载
| 名称 | 说明 |
|---|---|
| GetWorkingArea(Point) |
检索离指定点最近的工作区。 工作区是显示器的桌面区域,不包括任务栏、停靠窗口和停靠工具栏。 |
| GetWorkingArea(Rectangle) |
检索包含指定矩形最大部分的显示器的工作区。 工作区是显示器的桌面区域,不包括任务栏、停靠窗口和停靠工具栏。 |
| GetWorkingArea(Control) |
检索包含指定控件最大区域的显示器的工作区。 工作区是显示器的桌面区域,不包括任务栏、停靠窗口和停靠工具栏。 |
GetWorkingArea(Point)
- Source:
- Screen.cs
- Source:
- Screen.cs
- Source:
- Screen.cs
- Source:
- Screen.cs
- Source:
- Screen.cs
检索离指定点最近的工作区。 工作区是显示器的桌面区域,不包括任务栏、停靠窗口和停靠工具栏。
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.Rectangle
Public Shared Function GetWorkingArea (pt As Point) As Rectangle
参数
返回
指定工作区的 A 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)
- Source:
- Screen.cs
- Source:
- Screen.cs
- Source:
- Screen.cs
- Source:
- Screen.cs
- Source:
- Screen.cs
检索包含指定矩形最大部分的显示器的工作区。 工作区是显示器的桌面区域,不包括任务栏、停靠窗口和停靠工具栏。
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.Rectangle
Public Shared Function GetWorkingArea (rect As Rectangle) As Rectangle
参数
返回
指定工作区的 A Rectangle 。 在没有显示内容包含指定矩形的多个显示环境中,将返回最接近矩形的显示。
适用于
GetWorkingArea(Control)
- Source:
- Screen.cs
- Source:
- Screen.cs
- Source:
- Screen.cs
- Source:
- Screen.cs
- Source:
- Screen.cs
检索包含指定控件最大区域的显示器的工作区。 工作区是显示器的桌面区域,不包括任务栏、停靠窗口和停靠工具栏。
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.Rectangle
Public Shared Function GetWorkingArea (ctl As Control) As Rectangle
参数
返回
指定工作区的 A Rectangle 。 在没有显示控件包含指定控件的多个显示环境中,将返回最接近该控件的显示。