Adjust paper size
-
I have this code
BOOL CFormOptions::OnPreparePrinting(CPrintInfo* pInfo)
{
tagPDA pPrintDlg;
AfxGetApp()->GetPrinterDeviceDefaults (&pPrintDlg);
pInfo->m_pPD->m_pd.hDevMode = pPrintDlg.hDevMode;
LPDEVMODE devMode = pInfo->m_pPD->GetDevMode();
if (devMode)
{
if (m_legal)
devMode->dmPaperSize = 45; // DMPAPER_10X11; // DMPAPER_LEGAL;
else
devMode->dmPaperSize = DMPAPER_LEGAL; // _LETTERdevMode->dmPaperWidth = 2000; //devMode->dmPaperSize = DMPAPER\_10X11; GlobalUnlock(devMode); } if ( pInfo->m\_bPreview ) // normal print preview return DoPreparePrinting(pInfo); return DoPreparePrinting(pInfo);
}
and I can adjust the paper size from letter to legal. But if I try to adjust the paper size to DMPAPER_10X11 or any other size, the software ignores it and just uses letter size. How can I adjust the paper size to be something like DMPAPER_10X11? I tried adjust the PaperWidth as well and that is ignored as well. So Im not sure what Im doing wrong. Any help, any direction any one can provide will be greatly appreciated.
-
I have this code
BOOL CFormOptions::OnPreparePrinting(CPrintInfo* pInfo)
{
tagPDA pPrintDlg;
AfxGetApp()->GetPrinterDeviceDefaults (&pPrintDlg);
pInfo->m_pPD->m_pd.hDevMode = pPrintDlg.hDevMode;
LPDEVMODE devMode = pInfo->m_pPD->GetDevMode();
if (devMode)
{
if (m_legal)
devMode->dmPaperSize = 45; // DMPAPER_10X11; // DMPAPER_LEGAL;
else
devMode->dmPaperSize = DMPAPER_LEGAL; // _LETTERdevMode->dmPaperWidth = 2000; //devMode->dmPaperSize = DMPAPER\_10X11; GlobalUnlock(devMode); } if ( pInfo->m\_bPreview ) // normal print preview return DoPreparePrinting(pInfo); return DoPreparePrinting(pInfo);
}
and I can adjust the paper size from letter to legal. But if I try to adjust the paper size to DMPAPER_10X11 or any other size, the software ignores it and just uses letter size. How can I adjust the paper size to be something like DMPAPER_10X11? I tried adjust the PaperWidth as well and that is ignored as well. So Im not sure what Im doing wrong. Any help, any direction any one can provide will be greatly appreciated.
I think you might need to tell the devMode which fields are being initialized by setting the dmFields member example of setting landscape orientation:
devMode->dmOrientation = DMORIENT_LANDSCAPE;
devMode->dmFields |= DM_ORIENTATION;