bool CPrintFolder::CalcLayout(CDCHandle dcPrinter) { if(!dcPrinter.IsNull()) { CRect rcPage(0, 0, dcPrinter.GetDeviceCaps(PHYSICALWIDTH) - 2 * dcPrinter.GetDeviceCaps(PHYSICALOFFSETX), dcPrinter.GetDeviceCaps(PHYSICALHEIGHT) - 2 * dcPrinter.GetDeviceCaps(PHYSICALOFFSETY)); // Fix for 98...PHYSICALWIDTH seems to fail on 98? if (rcPage.right == 0) { rcPage.right = dcPrinter.GetDeviceCaps(HORZRES); rcPage.bottom = dcPrinter.GetDeviceCaps(VERTRES); } return CalcLayout(dcPrinter, rcPage); } return CalcLayout(dcPrinter, m_rcOutput); }
bool CPrintFolder::CalcLayout(CDCHandle dcPrinter, const CRect &rcPage) { m_bHasPrinter = !dcPrinter.IsNull(); if(m_bHasPrinter) { if (rcPage.right > 0) { m_rcOutput = rcPage; } _sizeLogPixels.cx = dcPrinter.GetDeviceCaps(LOGPIXELSX); _sizeLogPixels.cy = dcPrinter.GetDeviceCaps(LOGPIXELSY); } if (m_fontTitle.m_hFont != 0) m_fontTitle.DeleteObject(); if (m_font.m_hFont != 0) m_font.DeleteObject(); int nTitleFontSize = 16; int nFontSize = 8; int nPaddingSize = 4; //Set up the font for the titles on the intro and ending pages NONCLIENTMETRICS ncm = {0}; ncm.cbSize = sizeof(ncm); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); //Create the intro/end title font LOGFONT lf = ncm.lfMessageFont; lf.lfHeight = 0 - ::MulDiv(_sizeLogPixels.cy, nTitleFontSize, 72); m_fontTitle.CreateFontIndirect(&lf); lf.lfHeight = 0 - ::MulDiv(_sizeLogPixels.cy, nFontSize, 72); m_font.CreateFontIndirect(&lf); /////////////////////// //convert from 1/1000" to twips _rectExtents.left = m_rcOutput.left + MulDiv(m_rcMargin.left, _sizeLogPixels.cx, 1000); _rectExtents.right = m_rcOutput.right - MulDiv(m_rcMargin.right, _sizeLogPixels.cx, 1000); _rectExtents.top = m_rcOutput.top + MulDiv(m_rcMargin.top, _sizeLogPixels.cy, 1000); _rectExtents.bottom = m_rcOutput.bottom - MulDiv(m_rcMargin.bottom, _sizeLogPixels.cy, 1000); m_nPadding = ::MulDiv(_sizeLogPixels.cy, nPaddingSize, 72); m_nFooterHeight = ::MulDiv(_sizeLogPixels.cy, nFontSize, 72) * 2; m_nHeaderHeight = ::MulDiv(_sizeLogPixels.cy, nTitleFontSize, 72) * 2; // Do we want footers and headers? int nFooterHeaderHeight = 0; if (m_bShowFooter || m_bShowPageNumbers) { nFooterHeaderHeight += m_nFooterHeight; } if (m_bShowHeader) { nFooterHeaderHeight += m_nHeaderHeight; } int nImageRows = m_bPrintOnePerPage ? 1 : _sizeRowsColumns.cy; int nImageColumns = m_bPrintOnePerPage ? 1 : _sizeRowsColumns.cx; // Calculate the thumbnail size _sizeSection.cx = ((_rectExtents.right - _rectExtents.left) / nImageColumns); _sizeSection.cy = (((_rectExtents.bottom - _rectExtents.top) - nFooterHeaderHeight) / nImageRows); if (_sizeSection.cx < 10 || _sizeSection.cy < 10) { return false; } _sizeThumbNail = _sizeSection; _sizeThumbNail.cy -= (m_nPadding * 2); _sizeThumbNail.cx -= (m_nPadding * 2); if (_sizeThumbNail.cy < 10) { return false; } m_nMaxPage = GetPageCount(); return true; }