BrightnessTray.WindowPositioning.GetCursorPosition C# (CSharp) Method

GetCursorPosition() public static method

Returns the cursor's current position as a System.Windows.Point.
public static GetCursorPosition ( ) : Point
return Point
        public static Point GetCursorPosition()
        {
            NativeMethods.POINT result;
            if (NativeMethods.GetCursorPos(out result))
                return result;
            else
                // Failed to retrieve mouse position
                // Simply return (0,0) to continue instead of crashing
                return new Point(0,0);
        }

Usage Example

        /// <summary>
        /// Hides the window
        /// </summary>
        private void HideWindow()
        {
            // note if mouse is over the notify icon when hiding the window
            // if it is, we will assume that the user clicked the icon to hide the window
            this.MouseClickToHideNotifyIcon = WindowPositioning.IsCursorOverNotifyIcon(this.NotifyIcon) && WindowPositioning.IsNotificationAreaActive;
            if (this.MouseClickToHideNotifyIcon)
            {
                this.MouseClickToHideNotifyIconPoint = WindowPositioning.GetCursorPosition();
            }

            this.ReleaseHandlers();
            this.Visibility = Visibility.Hidden;
        }
All Usage Examples Of BrightnessTray.WindowPositioning::GetCursorPosition