示例#1
0
        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()));
        }
示例#2
0
        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);
        }
示例#3
0
 private static Point GetScreenPosition()
 {
     return(NativeMethodsSafe.GetCursorPos().ToPresentationPoint());
 }
示例#4
0
 private Point GetScreenPosition(IntPtr handle, IntPtr lParam)
 {
     return(NativeMethodsSafe.ClientToScreen(handle, WinAPIHelper.GetPoint(lParam)).ToPresentationPoint());
 }