Printing a custom control
-
I have a custom control that i do all the drawing on. If i want to print the control can i just replace the DC with a DC i get from CPrintDialog? This works but it prints reeeally small. How can i get it to print so it is the same size as on the screen? Scott
-
I have a custom control that i do all the drawing on. If i want to print the control can i just replace the DC with a DC i get from CPrintDialog? This works but it prints reeeally small. How can i get it to print so it is the same size as on the screen? Scott
your screen is probably at 96 DPI, but the printer is likely 300 or 600 DPI. so, it's drawing with the same number of dots, but the dots are much smaller. what you need to do is to set the printer DPI (in effect) to the same as your screen DPI. you can do this by adjust the DC's extents (see SetViewportExtent and SetWindowExtent and maybe SetMappingMode). this might work for you: pDC->SetMapMode(MM_ISOTROPIC); pDC->SetWindowExt(desiredDPI); pDC->SetViewportExt(pDC->GetDeviceCaps(LOGPIXELSX), pDC->GetDeviceCaps(LOGPIXELSY)); -c
When history comes, it always takes you by surprise.
-
your screen is probably at 96 DPI, but the printer is likely 300 or 600 DPI. so, it's drawing with the same number of dots, but the dots are much smaller. what you need to do is to set the printer DPI (in effect) to the same as your screen DPI. you can do this by adjust the DC's extents (see SetViewportExtent and SetWindowExtent and maybe SetMappingMode). this might work for you: pDC->SetMapMode(MM_ISOTROPIC); pDC->SetWindowExt(desiredDPI); pDC->SetViewportExt(pDC->GetDeviceCaps(LOGPIXELSX), pDC->GetDeviceCaps(LOGPIXELSY)); -c
When history comes, it always takes you by surprise.
What should the desiredDPI be? I tried 96 and it seems to work pretty good but it prints everything a little smaller than it should be. I can play around with desiredDPI and get it to print almost exactly like it is on the screen but there's got to be a way to figure what this value should be? Scott
-
What should the desiredDPI be? I tried 96 and it seems to work pretty good but it prints everything a little smaller than it should be. I can play around with desiredDPI and get it to print almost exactly like it is on the screen but there's got to be a way to figure what this value should be? Scott