-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is the purpose of ScreenToClient and ClientToScreen in NativeWindow.cs? #22
Comments
Hi, thanks for bringing this up.
IntentThis does the conversion in relation to the window (i.e, taking the NonClient area, based on the style of the Window - It may have a title bar, it may not. It may be borderless, it may not. It relieves the user of the API from thinking about these complexities). This is very useful when the window has children (which it usually does). Say, have a native window that is drawing a bunch of DirectX items. Now, you can just pass their co-ordinates onto these methods to get them in correct relation to the window. The adjustment is done with |
Also adding to that, it exposes a You will have to do this at some point to build a correct layout with a set of children. This just facilitates that. Please have a look at the Non normal NC windows are in most cases notoriously complicated and hard to implement. This is one of those things that help in implementing such so effortlessly. |
Right, thanks for elaborating. I'm sure the default implementation is useful for the purposes you describe, however for the basic case of having a regular overlapped window, it does the wrong thing, at least from the perspective of someone coming from a WinAPI background. So it would be useful if the different semantics of these methods were somehow indicated. |
From the perspective of the May be |
It does, but I'm not quite sure why taking the perspective of Windows is relevant. Using the word "client" in the sense of "client area" for anything other than the client area of a window as defined by the API docs is confusing, and at the very least should be explicitly documented.
Frankly, I'm not sure what to call it. Take |
How about |
I tried using the
ScreenToClient
andClientToScreen
methods inWinApi/WinApi/Windows/NativeWindow.cs
because I thought they did the same thing as the Windows functions of the same name. But, after getting unexpected results, I noticed that the methods hadAdjustWindowRectEx
/InverseAdjustWindowRectEx
calls in them as well, which results in something other than a simple client/screen coordinate transformation. This left me confused as to the purpose of the methods, so could you please clarify whether the intent really is something other than a simple client/screen coordinate transformation?The text was updated successfully, but these errors were encountered: