I’ve been struggling with a clipping problem with a window with non-zero window origin because I didn’t realize SelectClipRgn required device units.
So given that I have determined the viewport origin and the window origin as follows…
POINT VP_Org, WN_Org;
GetViewportOrgEx (dc, VP_Org);
GerWindowOrgEx (dc, WM_Org);
and I have a clipping region R in logical coordinates, how does one convert R to device units for use in defining a clipping region?
In other words, how do I transform R so that the following works.
RECT R;
ClipRgn = CreateRectRgn (R.left, R.top, R.right, R.bottom)
SelectClipRgn (dc, ClipRgn)
I know that it looks something like
R.top = R.top - WN_Org.y +- VP_Org.y;
from experiment but don’t know what sign to use for the viewport.
You can use the LPtoDP function: