I know how to get the cursor's position :
int X = Cursor.Position.X;
int Y = Cursor.Position.Y;
But this is relative to the screen. How do i get the coordinates relative to my Form?
The cursor position is represented by the line number and the character number and signifies where the next character will be displayed. For example, cursor position 1,1 always indicates the upper-leftmost corner position on the terminal. Cursor position 10,30 indicates the 30th character position on the 10th line.
Declare two CSS variables, --x and --y, used to track the position of the mouse on the button. Declare a CSS variable, --size, used to modify the gradient's dimensions. Use background: radial-gradient(circle closest-side, pink, transparent); to create the gradient at the correct position. Use Document.
To get the mouse position in React: Set the onMouseMove prop on an element or add an event listener on the window object. Provide an event handler function. Access relevant properties on the event object.
Use the Control.PointToClient
method. Assuming this
points to the form in question:
var relativePoint = this.PointToClient(new Point(X, Y));
Or simply:
var relativePoint = this.PointToClient(Cursor.Position);
I would use PointToClient
like this:
Point p = yourForm.PointToClient(Cursor.Position);
//if calling it in yourForm class, just replace yourForm with this or simply remove it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With