void CSketcherView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) { CScrollView::OnPrepareDC(pDC, pInfo); CSketcherDoc* pDoc = GetDocument(); pDC->SetMapMode(MM_ANISOTROPIC); // Set the map mode CSize DocSize = pDoc->GetDocSize(); // Get the document size pDC->SetWindowExt(DocSize); // Now set the window extent // Get the number of pixels per inch in x and y int xLogPixels = pDC->GetDeviceCaps(LOGPIXELSX); int yLogPixels = pDC->GetDeviceCaps(LOGPIXELSY); // Calculate the viewport extent in x and y int xExtent = (DocSize.cx*m_Scale*xLogPixels)/100; int yExtent = (DocSize.cy*m_Scale*yLogPixels)/100; pDC->SetViewportExt(xExtent,yExtent); // Set viewport extent }
void CSketcherView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) { // TODO: Add your specialized code here and/or call the base class CScrollView::OnPrepareDC(pDC, pInfo); CSketcherDoc* pDoc = GetDocument(); pDC->SetMapMode(MM_ANISOTROPIC); // Set the map mode CSize DocSize = pDoc->GetDocSize(); // Get the document size // y extent must be negative because we want MM_LOENGLISH DocSize.cy = -DocSize.cy; // Change sign of y pDC->SetWindowExt(DocSize); // Now set the window extent // Get the number of pixels per inch in x and y int xLogPixels = pDC->GetDeviceCaps(LOGPIXELSX); int yLogPixels = pDC->GetDeviceCaps(LOGPIXELSY); // Calculate the viewport extent in x and y long xExtent = static_cast<long>(DocSize.cx)*m_Scale*xLogPixels/100L; long yExtent = static_cast <long>(DocSize.cy)*m_Scale*yLogPixels/100L; pDC->SetViewportExt(static_cast<int>(xExtent), static_cast<int>(-yExtent)); // Set viewport extent }