Screen.GetWorkingArea Method

Definition

Retrieves the working area of a display.

Overloads

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)

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.

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)

Source:
Screen.cs
Source:
Screen.cs
Source:
Screen.cs

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.

C#
public static System.Drawing.Rectangle GetWorkingArea(System.Drawing.Point pt);

Parameters

pt
Point

A Point that specifies the coordinates for which to retrieve the working area.

Returns

A Rectangle that specifies the working area. In multiple display environments where no display contains the specified point, the display closest to the point is returned.

Examples

The following code example demonstrates the use of PrimaryScreen property and the GetWorkingArea method. This method requires a form containing a button named Button1

C#
// 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);
}

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

GetWorkingArea(Rectangle)

Source:
Screen.cs
Source:
Screen.cs
Source:
Screen.cs

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.

C#
public static System.Drawing.Rectangle GetWorkingArea(System.Drawing.Rectangle rect);

Parameters

rect
Rectangle

The Rectangle that specifies the area for which to retrieve the working area.

Returns

A Rectangle that specifies the working area. In multiple display environments where no display contains the specified rectangle, the display closest to the rectangle is returned.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

GetWorkingArea(Control)

Source:
Screen.cs
Source:
Screen.cs
Source:
Screen.cs

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.

C#
public static System.Drawing.Rectangle GetWorkingArea(System.Windows.Forms.Control ctl);

Parameters

ctl
Control

The Control for which to retrieve the working area.

Returns

A Rectangle that specifies the working area. In multiple display environments where no display contains the specified control, the display closest to the control is returned.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10