Page 1 of 1

ScreenToClient inverted Y!

Posted: Fri Feb 13, 2009 6:03 pm
by parad0x13
I have a function:

Code: Select all

wxPoint Screen = ScreenToClient(wxGetMousePosition());
that returns the correct xy position of the mouse within the client area of a window, but I was wondering if there is a way of inverting the y axis so that the bottom would be 0 and the top would be Screen.y

Any help would be greatly appreciated

-Thank You

Posted: Fri Feb 13, 2009 6:12 pm
by JimFairway
Hi,

How about:

Code: Select all

wxPoint Screen = ScreenToClient(wxGetMousePosition());
Screen.y = GetClientSize().GetHeight() - Screen.y;
Hope that helps,

Jim

Posted: Fri Feb 13, 2009 6:16 pm
by parad0x13
Yes, this is EXACTLY what I needed

Thank you very much!

Posted: Fri Feb 13, 2009 6:24 pm
by Disch
You might want to subtract an additional one:

Code: Select all

Screen.y = GetClientSize().GetHeight() - Screen.y - 1;
Without it, the range becomes [1-height] instead of the traditional [0-height)