Puoi ottenere/impostare i confini dell'area di lavoro (per intenderci, l'area che occupano le finestre massimizzate) con la property DWA.DesktopWorkingArea.
codice:
using System;
using System.Runtime.InteropServices;
namespace SetDeskWA
{
/// <summary>
/// Rectangle used by API functions
/// </summary>
public struct APIRectangle
{
public int Left;
public int Top;
public int Right;
public int Bottom;
public override string ToString()
{
return "{Left=" + Left.ToString() + ",Top=" + Top.ToString() + ",Right=" + Right.ToString() + ",Bottom=" + Bottom.ToString() + "}";
}
public APIRectangle(int Left, int Top, int Right, int Bottom)
{
this.Left=Left;
this.Top=Top;
this.Right=Right;
this.Bottom=Bottom;
}
};
/// <summary>
/// Desktop Working Area routines
/// </summary>
public static class DWA
{
private const int SPI_SETWORKAREA = 47;
private const int SPI_GETWORKAREA = 48;
[DllImport("user32.dll")]
private static extern bool SystemParametersInfo(int uiAction, int uiParam, ref APIRectangle rect, int fWinIni);
public static APIRectangle DesktopWorkingArea
{
get
{
APIRectangle WA = new APIRectangle();
if(!SystemParametersInfo(SPI_GETWORKAREA,0,ref WA,0))
throw new System.ComponentModel.Win32Exception();
return WA;
}
set
{
if(!SystemParametersInfo(SPI_SETWORKAREA,0,ref value,0))
throw new System.ComponentModel.Win32Exception("Used rectangle: " + value.ToString());
}
}
}
}