Exemple #1
0
        public User32Point ScreenToClient(User32Point rect)
        {
            User32Point clientPoint = rect;

            ScreenToClientInPlace(ref clientPoint);
            return(clientPoint);
        }
Exemple #2
0
        public User32Point ClientToScreen(User32Point point)
        {
            User32Point screenPoint = point;

            ClientToScreenInPlace(ref screenPoint);
            return(screenPoint);
        }
Exemple #3
0
 public bool ScreenToClientInPlace(ref User32Point point)
 {
     unsafe
     {
         fixed(User32Point *lpPoint = &point)
         {
             return(User32APIs.ScreenToClient(Hwnd, lpPoint));
         }
     }
 }
Exemple #4
0
 public bool ClientToScreenInPlace(ref User32Point point)
 {
     unsafe
     {
         fixed(User32Point *lpPoint = &point)
         {
             return(User32APIs.ClientToScreen(Hwnd, lpPoint));
         }
     }
 }
Exemple #5
0
        public static Point?GetCaretPosition(IServiceProvider serviceProvider)
        {
            try
            {
                var vsTextManager = (IVsTextManager)serviceProvider.GetService(typeof(SVsTextManager));

                ErrorHandler.ThrowOnFailure(vsTextManager.GetActiveView(Convert.ToInt32(true), null, out var activeView));
                if (activeView == null)
                {
                    return(null);
                }

                ErrorHandler.ThrowOnFailure(activeView.GetCaretPos(out var caretLine, out var caretColumn));

                var interopPoint = new POINT[1];
                ErrorHandler.ThrowOnFailure(activeView.GetPointOfLineColumn(caretLine + 1, caretColumn + 1, interopPoint));

                var p = new User32Point(interopPoint[0].x, interopPoint[0].y);
                ErrorHandler.ThrowOnFailure(ClientToScreen(activeView.GetWindowHandle(), p));

                var wpfTextView = GetWpfTextView(serviceProvider, activeView) as Visual;
                if (wpfTextView != null)
                {
                    var target = PresentationSource.FromVisual(wpfTextView)?.CompositionTarget;
                    if (target != null)
                    {
                        var transformedPoint = target.TransformFromDevice.Transform(new Point(p.x, p.y));
                        return(transformedPoint);
                    }
                }

                return(new Point(p.x, p.y));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                return(null);
            }
        }
Exemple #6
0
 public static extern int ClientToScreen(IntPtr hWnd, [In, Out] User32Point pt);
Exemple #7
0
        public static WindowControl WindowFromPoint(User32Point point)
        {
            IntPtr hwnd = User32APIs.WindowFromPoint(point);

            return(new WindowControl(hwnd));
        }
Exemple #8
0
 public WindowControl ChildWindowFromPointEx(User32Point point, uint uFlags)
 {
     return(new WindowControl(User32APIs.ChildWindowFromPointEx(Hwnd, point, uFlags)));
 }
Exemple #9
0
 public WindowControl ChildWindowFromPoint(User32Point point)
 {
     return(new WindowControl(User32APIs.ChildWindowFromPoint(Hwnd, point)));
 }