/// <summary> /// Get the region for a window /// </summary> /// <param name="interopWindow">InteropWindow</param> public static Region GetRegion(this IInteropWindow interopWindow) { using (var region = Gdi32Api.CreateRectRgn(0, 0, 0, 0)) { if (region.IsInvalid) { return(null); } var result = User32Api.GetWindowRgn(interopWindow.Handle, region); if (result != RegionResults.Error && result != RegionResults.NullRegion) { return(Region.FromHrgn(region.DangerousGetHandle())); } } return(null); }