Windows Form
I'm using the DragOver event on a layoutpanel and the DragEventArgs returns the X/Y coordinates of the mouse in relation to the screen. I know there is a function to translate this in to the position of the mouse over the control, but I'm having difficulty locating it.
How to get mouse position over a certain control
Asked Answered
This answer could be improved with the code sample being put here instead of a link away. –
Nonviolence
Well you can feel free to edit it and put that code sample right in. –
Copro
I haven't figured out what the code should be yet or I would :) –
Nonviolence
Try using PointToClient
method to compute the location of the specified screen point into client coordinates.
private void DragDrop(object sender, DragEventArgs e)
{
Point point = this.PointToClient(new Point(e.X, e.Y));
// then use point.X and point.Y instead of e.X and e.Y
}
© 2022 - 2024 — McMap. All rights reserved.