View Single Post
Old 08-03-2018, 12:52 AM   #1
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default WDL/SWELL: GetWindowRect and flipped coordinates

swell-function.h states:
Code:
/*
** Notes: common win32 code like this:
**   RECT r;
**   GetWindowRect(hwnd,&r); 
**   ScreenToClient(otherhwnd,(LPPOINT)&r);
**   ScreenToClient(otherhwnd,((LPPOINT)&r)+1);
** does work, however be aware that in certain instances r.bottom may be less 
** than r.top, due to flipped coordinates. SetWindowPos and other functions 
** handle negative heights gracefully, and you should too.
**
** Note: GetWindowContentViewRect gets the rectangle of the content view (pre-NCCALCSIZE etc)
*/
* I couldn't find reference to "flipped coordinates" in the standard Win32 API. Are flipped coordinates unique to WDL/SWELL?

* In standard Win32 rects, the pixel whose coordinates are ( right, bottom ) lies immediately *outside* of the rectangle.

If the coordinates are flipped, which are inside the actual rectangle and which are outside?

For example, if r.bottom < r.top, are both pixels now outside the rectangle, with (left,top) sticking out at the bottom of the rectangle and (right,bottom) sticking out to the right?

* Can the rect also be flipped horizontally so that r.right < r.left?

* If the coordinates are flipped, how are ScreenToClient and ClientToScreen calculated? Relative to the flipped (r.left, r.top), or to the actual left, top corner of the rect [which is either (r.left, r.bottom) or (r.left, r.bottom-1), depending on whether r.bottom is always outside the rect]?

Last edited by juliansader; 08-03-2018 at 01:12 AM.
juliansader is offline   Reply With Quote