Im learning win32 API with "Programming Windows 5th" by Charles Petzold. In the GDI section, im quite confused about the SetViewportOrgEX() and SetWindowOrgEx() when it come into example. Here what the book say:
"Windows provides the functions
for changing the viewport and window origins. These functions have the effect of shifting the axes so that the logical point
no longer refers to the upper left corner. Generally, you'll use either SetViewportOrgEx or SetWindowOrgEx but not both.
Here's how the functions work: If you change the viewport origin to
, the logical point
will be mapped to the device point (xViewOrg, yViewOrg). If you change the window origin to
, the logical point (xWinOrg, yWinOrg) will be mapped to the device point
, which is the upper left corner. Regardless of any changes you make to the window and viewport origins, the device point
is always the upper left corner of the client area. "
Here what im confused:
"What you probably don't want to do (unless you know what's going to happen) is to use both function calls together:
SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;
SetWindowOrgEx (hdc, -cxClient / 2, -cyClient / 2, NULL) ;
This means that the logical point
is mapped to the device point (cxClient/2, cyClient/2)"
After the first function, the logical point
is set to the device point, which is the center of the client area, it means that the point
(-cxClient / 2, -cyClient / 2)
is the upper left corner of the client, right? So the second function sets that logical point to the device point
, which is the upper left corner, not the device point
. Am i right? please help me clear it.
More detail about this with some figures can be found on this page: http://www-user.tu-chemnitz.de/~heha/petzold/ch05f.htm