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()); }