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.Rectangle
Public 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.Rectangle
Public 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.Rectangle
Public Shared Function GetWorkingArea (ctl As Control) As Rectangle
參數
傳回
Rectangle,指定工作區域。 在任何顯示皆不包含指定控制項的多重顯示環境中,會傳回離控制項最近的顯示。