[Mono-winforms-list] Mouse position question

PFJ pjohnson1 at uclan.ac.uk
Mon Dec 21 08:39:25 EST 2009


Hi,

I can find where my mouse is clicked on a form using MouseEventArgs e.X and
e.Y and the world is good. However, if my window size is varied, the
position of X and Y will change depending on the size of the window.

Is there a nice, simple way to find the X and Y position that will always
work?

The logic I've tried so far.

In LoadForm, get the initial size of the window and set this to be a scale
factor (scale_x, scale_y) of 1 (okay, that means needing the scale factor
variable to be a float which means casting around later). Set a resize event
up, so if the window size changes, the scale factor can be changed.

When the mouse click happens though, the rescale number should be correct
(e.g. I have an eye at 150,150 with the scale = 1, if I half the window x
and y, the eye should be 75, 75, but I need it to be read as if it's still
150,150). I've tried various conditions (if xscale<1 then divide else
multiply), but I'm getting nowhere.

Any ideas on this?

TTFN

Paul
-- 
View this message in context: http://old.nabble.com/Mouse-position-question-tp26874088p26874088.html
Sent from the Mono - WinForms mailing list archive at Nabble.com.



More information about the Mono-winforms-list mailing list