ScreenToClient inverted Y! Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
parad0x13
Experienced Solver
Experienced Solver
Posts: 79
Joined: Tue Jan 06, 2009 3:09 am

ScreenToClient inverted Y!

Post 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
JimFairway
wxWorld Domination!
wxWorld Domination!
Posts: 1059
Joined: Sun Dec 30, 2007 6:40 pm
Location: Canada

Post by JimFairway »

Hi,

How about:

Code: Select all

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

Jim
OS: Vista SP1, wxWidgets 2.8.7.
parad0x13
Experienced Solver
Experienced Solver
Posts: 79
Joined: Tue Jan 06, 2009 3:09 am

Post by parad0x13 »

Yes, this is EXACTLY what I needed

Thank you very much!
User avatar
Disch
Experienced Solver
Experienced Solver
Posts: 99
Joined: Wed Oct 17, 2007 2:01 am

Post 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)
Post Reply