NativeMethods.RECT CalcParentWindowRect(IntPtr hwnd) { var adjustRect = new NativeMethods.RECT(); var style = UnsafeNativeMethods.GetWindowLong(hwnd, NativeMethods.GWL_STYLE); var exStyle = UnsafeNativeMethods.GetWindowLong(hwnd, NativeMethods.GWL_EXSTYLE); UnsafeNativeMethods.AdjustWindowRectEx(ref adjustRect, style & ~NativeMethods.WS_CAPTION, 0, exStyle); var windowRect = new NativeMethods.RECT(); UnsafeNativeMethods.GetWindowRect(hwnd, ref windowRect); windowRect.left -= adjustRect.left; windowRect.top -= adjustRect.top; windowRect.right -= adjustRect.right; windowRect.bottom -= adjustRect.bottom; return(windowRect); }