Export (0) Print
Expand All

Screen.GetWorkingArea Method (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.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public static Rectangle GetWorkingArea (
	Point pt
)
public static Rectangle GetWorkingArea (
	Point pt
)
public static function GetWorkingArea (
	pt : Point
) : Rectangle
Not applicable.

Parameters

pt

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

Return Value

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.

The following code example demonstrates the use of PrimaryScreen property and the GetWorkingArea method. This method requires a form containing a button named 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 = 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 void button1_Click(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.get_PrimaryScreen().get_WorkingArea();
    // Set the size of the form slightly less than size of 
    // working rectangle.
    this.set_Size(new System.Drawing.Size(workingRectangle.get_Width()
        - 10, workingRectangle.get_Height() - 10));
    // Set the location so the entire form is visible.
    this.set_Location(new System.Drawing.Point(5, 5));
} //Button1_Click

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft