I found a few comments on the internet about how to force landscape printing with MFC. I didn’t find a clear and simple answer in the first page of Google results so I found a page that had more information than was needed and took just the part that worked for me. If you are using some variation of the CView class to print, override OnPrepareDC() and do this:
void CMyView::OnPrepareDC( CDC* pDC, CPrintInfo* pInfo ) { if( pDC->IsPrinting () ) { DEVMODE* pDevMode = pInfo->m_pPD->GetDevMode(); pDevMode->dmOrientation = DMORIENT_LANDSCAPE; pDevMode->dmFields |= DM_ORIENTATION; pDC->ResetDC( pDevMode ); } CView::OnPrepareDC( pDC, pInfo ); }
I added code to this to check the size of my document and I adjust the mode to best fit the document on the page.
Leave a comment