Exemple #1
0
        /// <summary>
        /// Returns the mouse cursor location.  This method is necessary during
        /// a drag-drop operation because the WPF mechanisms for retrieving the
        /// cursor coordinates are unreliable.
        /// </summary>
        /// <param name="relativeTo">The Visual to which the mouse coordinates will be relative.</param>
        public static System.Windows.Point GetMousePosition(System.Windows.Media.Visual relativeTo)
        {
            User32.POINT mouse = new User32.POINT();
            GetCursorPos(ref mouse);

            // Using PointFromScreen instead of Dan Crevier's code (commented out below)
            // is a bug fix created by William J. Roberts.  Read his comments about the fix
            // here: http://www.codeproject.com/useritems/ListViewDragDropManager.asp?msg=1911611#xx1911611xx
            return(relativeTo.PointFromScreen(new System.Windows.Point((double)mouse.X, (double)mouse.Y)));
        }
Exemple #2
0
 private static extern bool GetCursorPos(ref User32.POINT pt);