К сожалению ничего не выходит :( Все равно "пустой" RECT :(
public partial class Form1 : Form
{
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern bool GetUpdateRect(IntPtr hWnd, ref RECT lpRect, bool bErase);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern bool GetWindowRect(IntPtr handle, ref RECT rect);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
static extern IntPtr GetDC(IntPtr hWnd);
RECT rc = new RECT();
public Form1()
{
InitializeComponent();
}
public void GetUpdRectWindow()
{
if (GetWindowRect(GetDC(this.Handle), ref rc))
{
if (GetUpdateRect(GetDC(this.Handle), ref rc, true))
{
MessageBox.Show("Область получена!");
}
else
{
MessageBox.Show("Область не получена!");
}
}
}
private void button1_Click(object sender, EventArgs e)
{
GetUpdRectWindow();
}