public static HwndRectInfo GetRectInfo(IntPtr hwnd) { var clientNativeRect = NativeMethodsSafe.GetClientRect(hwnd); var windowScreenNativeRect = NativeMethodsSafe.GetWindowRect(hwnd); var topLeft = NativeMethodsSafe.ClientToScreen(hwnd, clientNativeRect.Position); var bottomRight = NativeMethodsSafe.ClientToScreen(hwnd, new POINT { x = clientNativeRect.Right, y = clientNativeRect.Bottom }); var clientScreenNativeRect = new RECT { Left = topLeft.x, Top = topLeft.y, Right = bottomRight.x, Bottom = bottomRight.y }; return(new HwndRectInfo(windowScreenNativeRect.ToPresentationRect(), clientNativeRect.ToPresentationRect(), clientScreenNativeRect.ToPresentationRect())); }
public static WindowHitTestResult HitTest(IntPtr hwnd) { if (hwnd == IntPtr.Zero) { return(WindowHitTestResult.Outside); } var hwndRectInfo = GetRectInfo(hwnd); var cursorPoint = NativeMethodsSafe.GetCursorPos().ToPresentationPoint(); var insideClientArea = hwndRectInfo.ClientScreenRect.Contains(cursorPoint); var insideWindow = hwndRectInfo.WindowScreenRect.Contains(cursorPoint); if (insideWindow == false) { return(WindowHitTestResult.Outside); } return(insideClientArea ? WindowHitTestResult.ClientArea : WindowHitTestResult.NonClientArea); }
private static Point GetScreenPosition() { return(NativeMethodsSafe.GetCursorPos().ToPresentationPoint()); }
private Point GetScreenPosition(IntPtr handle, IntPtr lParam) { return(NativeMethodsSafe.ClientToScreen(handle, WinAPIHelper.GetPoint(lParam)).ToPresentationPoint()); }