示例#1
0
文件: MouseEx.cs 项目: dxm007/Droppy
        /// <summary>
        /// Uses Win32 API to return mouse pointer position relative to a specific Visual. This
        /// function is provided because WPF's mouse API becomes unreliable under certain circumstances,
        /// like during drag-drop operations.
        /// </summary>
        /// <param name="relativeTo">Visual against which mouse position is reported</param>
        /// <returns>Mouse pointer location relative to passed in Visual</returns>
        public static Point GetPosition(Visual relativeTo)
        {
            Win32.Point w32Mouse = new Win32.Point();

            Win32.GetCursorPos( ref w32Mouse );

            return relativeTo.PointFromScreen( new Point( w32Mouse.X, w32Mouse.Y ) );
        }
示例#2
0
文件: MouseEx.cs 项目: dxm007/Droppy
        /// <summary>
        /// Uses Win32 API to return mouse pointer position relative to a specific Visual. This
        /// function is provided because WPF's mouse API becomes unreliable under certain circumstances,
        /// like during drag-drop operations.
        /// </summary>
        /// <param name="relativeTo">Visual against which mouse position is reported</param>
        /// <returns>Mouse pointer location relative to passed in Visual</returns>
        public static Point GetPosition(Visual relativeTo)
        {
            Win32.Point w32Mouse = new Win32.Point();

            Win32.GetCursorPos(ref w32Mouse);

            return(relativeTo.PointFromScreen(new Point(w32Mouse.X, w32Mouse.Y)));
        }