Size of paper in MFC print preview?
-
I want to use the print / print preview of the MFC framework. I want to stretch my dawing on the whole size of the paper. So, here my question: How can I get the size (in pixel) of the whole paper, so that I can stretch my drawing so that it uses the whole paper. Daniel ;) --------------------------- Never change a running system!
-
I want to use the print / print preview of the MFC framework. I want to stretch my dawing on the whole size of the paper. So, here my question: How can I get the size (in pixel) of the whole paper, so that I can stretch my drawing so that it uses the whole paper. Daniel ;) --------------------------- Never change a running system!
Do it like that : CRect crPrintPaperRect = CRect( 0, 0, pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES) ); for details have a look at the msdn : int CDC::GetDeviceCaps( int nIndex ) - HORZSIZE Width of the physical display (in millimeters). - VERTSIZE Height of the physical display (in millimeters). - HORZRES Width of the display (in pixels). - VERTRES Height of the display (in raster lines).
-
Do it like that : CRect crPrintPaperRect = CRect( 0, 0, pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES) ); for details have a look at the msdn : int CDC::GetDeviceCaps( int nIndex ) - HORZSIZE Width of the physical display (in millimeters). - VERTSIZE Height of the physical display (in millimeters). - HORZRES Width of the display (in pixels). - VERTRES Height of the display (in raster lines).
Thanks! It works! :) I use it like in the following code:
if (pDC->IsPrinting())
{
rtClient = CRect(0, 0,
pDC->GetDeviceCaps(HORZRES),
pDC->GetDeviceCaps(VERTRES));
}
else
{
GetClientRect(&rtClient);
}Daniel ;) --------------------------- Never change a running system!
-
Thanks! It works! :) I use it like in the following code:
if (pDC->IsPrinting())
{
rtClient = CRect(0, 0,
pDC->GetDeviceCaps(HORZRES),
pDC->GetDeviceCaps(VERTRES));
}
else
{
GetClientRect(&rtClient);
}Daniel ;) --------------------------- Never change a running system!
If you want to be really accurate, you should call DeviceCapabilities() to open the device that you will be printing to. One of the parameters to OpenPrinter is a good old DEVMODE struct (lots of good info). Also, you should look at the PHYSICALOFFSETX and PHYSICALOFFSETY to determine the non-printable areas of the physical page (YOUR MIN MARGIN). On laser printers, this is usually 0.25 inches around.
-
I want to use the print / print preview of the MFC framework. I want to stretch my dawing on the whole size of the paper. So, here my question: How can I get the size (in pixel) of the whole paper, so that I can stretch my drawing so that it uses the whole paper. Daniel ;) --------------------------- Never change a running system!
In print/preview in your OnPrint() procedure which generates the output, the paper size can always be found in the CPrintInfo::m_rectDraw object. So you should be able to read this rect value and StretchBlt the pic to this size. Roger Allen Sonork 100.10016 Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
-
In print/preview in your OnPrint() procedure which generates the output, the paper size can always be found in the CPrintInfo::m_rectDraw object. So you should be able to read this rect value and StretchBlt the pic to this size. Roger Allen Sonork 100.10016 Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
Thanks Roger! It works! Daniel ;) --------------------------- Never change a running system!