Jump to content

Questions about _WinAPI_ClientToScreen() and the Reverse


Recommended Posts

The documentation I've read concerning those functions on various fora as well as at Microsoft have failed to sufficiently enlighten me. The problem is the nomenclature. I realize that _WinAPI_ClientToScreen() "Converts the client coordinates of a specified point to screen coordinates." But I find that to be completely ambiguous.

What's a client in this context? I know that windows contain an inner client region that's user-controlled, and an outer region of decorations that is larger than the client region and is controlled by the system (normally). Is that what they're referring to in that function? An alternative meaning might be that the client region consists of the user-controllable region of an entire monitor, which might have negative coordinates if it's to the left of the Primary monitor, and the functions in question convert from these negative relative coordinates to the zero-based coordinates of the Virtual Screen.

I have little need for the former functionality, but the second interpretation is exactly what I'm looking for. If the reality is the former, are there functions that perform the coordinate transformations of the second? If so, what are they called?

Thanks!

Link to post
Share on other sites

OK, it looks like the _WinAPI_ClientToScreen / ScreenToClient functions don't quite do either of the two possibilities in my OP.  How's that for ambiguous?

It looks like these functions do a kind of combination of the two. What the CtoS function seems to do is to convert the left and top coordinates within the client-region of a window and converts them into what I'll call "Total Desktop" coordinates, which cover the entire set of monitors as a single space/region. The curious thing seems to be that the home coordinates of zero/zero appear to exist at the upper right corner of the right-most monitor, rather than the upper left coordinate of the primary monitor. Let me explain by showing what I see in actual practice...

If I create a window such that the upper left corner is placed at the upper left of the left-hand monitor (in my case, [-1842, 0]), then CtoS will return [-3681, 26]. And, for example, that value of 26 demonstrates that the function returns values that take into account the decorations of the window. But the return value of -3681 for the left coordinate demonstrates, obviously, that isn't merely taking into account the decorations.  Because upper left of the Virtual Screen is [-1842, 0] and the width of the Virtual Screen is 3762. So it sure is hard to believe that the left-side decorations consume 81 pixels! So I'm still at least somewhat confused.

Finally, I'm still in the dark about the final sentence of my OP. Certainly I could transform the coordinates using the most basic arithmetic -- simple add and subtract. But one of the main reasons for the Windows API functions relating to multiple monitors is to cover all the different possible monitor arrangements, including where one of the middle monitors is non-functional so that it must not be included in the Virtual Screen. So again, does anyone know if such functions exist and what their names are?

Thanks!

 

Edited by Mbee
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...