[Mono-winforms-list] Mouse position question

Stefanos Apostolopoulos stapostol at gmail.com
Sun Dec 27 07:21:29 EST 2009


On your mouse event handler, divide the current mouse position by the 
window size. This will give you two floating point values between 0 and 
1, where 0 means the top or left edge of the window and 1 the bottom or 
right edge.

The point (x, y) = (0.5, 0.5) is the exact center of the window.

στις 21/12/2009 3:44 μμ, O/H Petit Eric έγραψε:
> I m not sure to completely understand your question, but did you look
> at screen bound ?
> yu should know, the position of the form on the screen and it size ....
>
> 2009/12/21 PFJ<pjohnson1 at uclan.ac.uk>:
>    
>> 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.
>>
>> _______________________________________________
>> Mono-winforms-list maillist  -  Mono-winforms-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-winforms-list
>>
>>      
>
>
>    



More information about the Mono-winforms-list mailing list