private static void RaiseNonClientMouseMessageAsClient(IntPtr hwnd, int msg, IntPtr lparam) { var point = new Core.Platform.Point { X = NativeMethods.GetXlParam(lparam.ToInt32()), Y = NativeMethods.GetYlParam(lparam.ToInt32()) }; NativeMethods.ScreenToClient(hwnd, ref point); NativeMethods.SendMessage(hwnd, msg + 513 - 161, new IntPtr(PressedMouseButtons), NativeMethods.MakeParam(point.X, point.Y)); }
private static RECT GetClientRectRelativeToWindowRect(IntPtr hwnd) { RECT lpRect1; NativeMethods.GetWindowRect(hwnd, out lpRect1); RECT lpRect2; NativeMethods.GetClientRect(hwnd, out lpRect2); var point = new Core.Platform.Point { X = 0, Y = 0 }; NativeMethods.ClientToScreen(hwnd, ref point); lpRect2.Offset(point.X - lpRect1.Left, point.Y - lpRect1.Top); return(lpRect2); }
protected IntPtr ComputeCornerRadiusRectRegion(Int32Rect rect, CornerRadius cornerRadius) { if (cornerRadius.TopLeft == cornerRadius.TopRight && cornerRadius.TopLeft == cornerRadius.BottomLeft && cornerRadius.BottomLeft == cornerRadius.BottomRight) { return(ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height, (int)cornerRadius.TopLeft)); } var num1 = IntPtr.Zero; var num2 = IntPtr.Zero; var num3 = IntPtr.Zero; var num4 = IntPtr.Zero; var num5 = IntPtr.Zero; var num6 = IntPtr.Zero; var num7 = IntPtr.Zero; var num8 = IntPtr.Zero; var num9 = IntPtr.Zero; var num10 = IntPtr.Zero; try { num1 = ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height, (int)cornerRadius.TopLeft); num2 = ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height, (int)cornerRadius.TopRight); num3 = ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height, (int)cornerRadius.BottomLeft); num4 = ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height, (int)cornerRadius.BottomRight); var point = new Core.Platform.Point { X = rect.X + rect.Width / 2, Y = rect.Y + rect.Height / 2 }; num5 = NativeMethods.CreateRectRgn(rect.X, rect.Y, point.X + 1, point.Y + 1); num6 = NativeMethods.CreateRectRgn(point.X - 1, rect.Y, rect.X + rect.Width, point.Y + 1); num7 = NativeMethods.CreateRectRgn(rect.X, point.Y - 1, point.X + 1, rect.Y + rect.Height); num8 = NativeMethods.CreateRectRgn(point.X - 1, point.Y - 1, rect.X + rect.Width, rect.Y + rect.Height); num9 = NativeMethods.CreateRectRgn(0, 0, 1, 1); num10 = NativeMethods.CreateRectRgn(0, 0, 1, 1); NativeMethods.CombineRgn(num10, num1, num5, NativeMethods.CombineMode.RgnAnd); NativeMethods.CombineRgn(num9, num2, num6, NativeMethods.CombineMode.RgnAnd); NativeMethods.CombineRgn(num10, num10, num9, NativeMethods.CombineMode.RgnOr); NativeMethods.CombineRgn(num9, num3, num7, NativeMethods.CombineMode.RgnAnd); NativeMethods.CombineRgn(num10, num10, num9, NativeMethods.CombineMode.RgnOr); NativeMethods.CombineRgn(num9, num4, num8, NativeMethods.CombineMode.RgnAnd); NativeMethods.CombineRgn(num10, num10, num9, NativeMethods.CombineMode.RgnOr); } finally { if (num1 != IntPtr.Zero) { NativeMethods.DeleteObject(num1); } if (num2 != IntPtr.Zero) { NativeMethods.DeleteObject(num2); } if (num3 != IntPtr.Zero) { NativeMethods.DeleteObject(num3); } if (num4 != IntPtr.Zero) { NativeMethods.DeleteObject(num4); } if (num5 != IntPtr.Zero) { NativeMethods.DeleteObject(num5); } if (num6 != IntPtr.Zero) { NativeMethods.DeleteObject(num6); } if (num7 != IntPtr.Zero) { NativeMethods.DeleteObject(num7); } if (num8 != IntPtr.Zero) { NativeMethods.DeleteObject(num8); } if (num9 != IntPtr.Zero) { NativeMethods.DeleteObject(num9); } } return(num10); }
private static RECT GetClientRectRelativeToWindowRect(IntPtr hwnd) { RECT lpRect1; NativeMethods.GetWindowRect(hwnd, out lpRect1); RECT lpRect2; NativeMethods.GetClientRect(hwnd, out lpRect2); var point = new Core.Platform.Point {X = 0, Y = 0}; NativeMethods.ClientToScreen(hwnd, ref point); lpRect2.Offset(point.X - lpRect1.Left, point.Y - lpRect1.Top); return lpRect2; }
protected IntPtr ComputeCornerRadiusRectRegion(Int32Rect rect, CornerRadius cornerRadius) { if (cornerRadius.TopLeft == cornerRadius.TopRight && cornerRadius.TopLeft == cornerRadius.BottomLeft && cornerRadius.BottomLeft == cornerRadius.BottomRight) return ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height, (int) cornerRadius.TopLeft); var num1 = IntPtr.Zero; var num2 = IntPtr.Zero; var num3 = IntPtr.Zero; var num4 = IntPtr.Zero; var num5 = IntPtr.Zero; var num6 = IntPtr.Zero; var num7 = IntPtr.Zero; var num8 = IntPtr.Zero; var num9 = IntPtr.Zero; var num10 = IntPtr.Zero; try { num1 = ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height, (int) cornerRadius.TopLeft); num2 = ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height, (int) cornerRadius.TopRight); num3 = ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height, (int) cornerRadius.BottomLeft); num4 = ComputeRoundRectRegion(rect.X, rect.Y, rect.Width, rect.Height, (int) cornerRadius.BottomRight); var point = new Core.Platform.Point { X = rect.X + rect.Width/2, Y = rect.Y + rect.Height/2 }; num5 = NativeMethods.CreateRectRgn(rect.X, rect.Y, point.X + 1, point.Y + 1); num6 = NativeMethods.CreateRectRgn(point.X - 1, rect.Y, rect.X + rect.Width, point.Y + 1); num7 = NativeMethods.CreateRectRgn(rect.X, point.Y - 1, point.X + 1, rect.Y + rect.Height); num8 = NativeMethods.CreateRectRgn(point.X - 1, point.Y - 1, rect.X + rect.Width, rect.Y + rect.Height); num9 = NativeMethods.CreateRectRgn(0, 0, 1, 1); num10 = NativeMethods.CreateRectRgn(0, 0, 1, 1); NativeMethods.CombineRgn(num10, num1, num5, NativeMethods.CombineMode.RgnAnd); NativeMethods.CombineRgn(num9, num2, num6, NativeMethods.CombineMode.RgnAnd); NativeMethods.CombineRgn(num10, num10, num9, NativeMethods.CombineMode.RgnOr); NativeMethods.CombineRgn(num9, num3, num7, NativeMethods.CombineMode.RgnAnd); NativeMethods.CombineRgn(num10, num10, num9, NativeMethods.CombineMode.RgnOr); NativeMethods.CombineRgn(num9, num4, num8, NativeMethods.CombineMode.RgnAnd); NativeMethods.CombineRgn(num10, num10, num9, NativeMethods.CombineMode.RgnOr); } finally { if (num1 != IntPtr.Zero) NativeMethods.DeleteObject(num1); if (num2 != IntPtr.Zero) NativeMethods.DeleteObject(num2); if (num3 != IntPtr.Zero) NativeMethods.DeleteObject(num3); if (num4 != IntPtr.Zero) NativeMethods.DeleteObject(num4); if (num5 != IntPtr.Zero) NativeMethods.DeleteObject(num5); if (num6 != IntPtr.Zero) NativeMethods.DeleteObject(num6); if (num7 != IntPtr.Zero) NativeMethods.DeleteObject(num7); if (num8 != IntPtr.Zero) NativeMethods.DeleteObject(num8); if (num9 != IntPtr.Zero) NativeMethods.DeleteObject(num9); } return num10; }