SetMapMode ignores or clears SetViewportOrgEx (or SetWindowOrgEx or SetWorldTransform)
- From: RMurdock <topochicho@xxxxxxxxxxxxxx>
- Date: Thu, 10 Apr 2008 09:24:33 -0500
I am creating a DC that could be an EMF for going to the screen or a Printer DC.
This DC is passed to code that renders to the DC and is totally out of my control, I also might be playing an EMF to it that has SetMapMode internally.
Depending on user selections I may need to offset the DC to add or subtract a margin.
As long as the drawing code never calls SetMapMode everything works as expected, but the moment it does, then my previos calls to SetViewportOrgEx or SetWindowOrgEx or SetWorldTransform are ignored. I only need to call one of the offset functions, but none currently work.
hDC = CreateDC("WINSPOOL", pDevice, NULL, pDevMode);
SetMapMode(hDC, MM_ISOTROPIC);
SetGraphicsMode(hDC, GM_ADVANCED);
SetViewportOrgEx(hDC, MarginX * Res, MarginY * Res, NULL);
....
SetMapMode(hDC, MM_TWIPS);
SetGraphicsMode(hDC, GM_COMPATIBLE);
int left = 0;
int right = 4 * 1440;
int top = 0;
int bottom = -6 * 14400;
SelectObject(hDC, GetStockObject(BLACK_PEN));
SelectObject(hDC, GetStockObject(LTGRAY_BRUSH));
Rectangle(hDC, left, top, right, bottom);
Given the above code and setting Margin to the thickness of the papers margin should result in the rectangle being clipped, setting Margin to 0 should print the entire rectangle, starting from the first pritable pixel.
.
- Follow-Ups:
- Re: SetMapMode ignores or clears SetViewportOrgEx (or SetWindowOrgEx or SetWorldTransform)
- From: Mark Salsbery [MVP]
- Re: SetMapMode ignores or clears SetViewportOrgEx (or SetWindowOrgEx or SetWorldTransform)
- Prev by Date: Serious GDI Multithreading bug while printing to metafiles
- Next by Date: Re: GDI+ Image to Clipboard
- Previous by thread: Serious GDI Multithreading bug while printing to metafiles
- Next by thread: Re: SetMapMode ignores or clears SetViewportOrgEx (or SetWindowOrgEx or SetWorldTransform)
- Index(es):
Relevant Pages
|
Loading