Export (0) Print
Expand All
Expand Minimize

CWinApp::GetPrinterDeviceDefaults

Call this member function to prepare a printer device context for printing.

BOOL GetPrinterDeviceDefaults( 
   struct tagPDA* pPrintDlg  
);

pPrintDlg

A pointer to a PRINTDLG structure.

Nonzero if successful; otherwise 0.

Retrieves the current printer defaults from the Windows .INI file as necessary, or uses the last printer configuration set by the user in Print Setup.

void CMyApp::SetLandscapeMode()
{
   PRINTDLG pd;
   pd.lStructSize = (DWORD)sizeof(PRINTDLG);
   BOOL bRet = GetPrinterDeviceDefaults(&pd);
   if(bRet)
   {
      // protect memory handle with ::GlobalLock and ::GlobalUnlock
      DEVMODE FAR *pDevMode = (DEVMODE FAR *)::GlobalLock(pd.hDevMode);
      // set orientation to landscape
      pDevMode->dmOrientation = DMORIENT_LANDSCAPE;
      ::GlobalUnlock(pd.hDevMode);
   }
}

Header: afxwin.h

Show:
© 2014 Microsoft