mgordon
asked on
Forcing landscape orientation
How can I force Print Preview to show a particular view in landscape orientation without user intervention?
(and Print to print it, naturally!)
Mike.
(and Print to print it, naturally!)
Mike.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is working code to set landscape mode:
PrintDialog.m_pd.hDevMode = ::GlobalAlloc( GHND, sizeof(DEVMODE) );
DEVMODE * devMode = (DEVMODE *) ::GlobalLock( PrintDialog.m_pd.hDevMode );
devMode->dmSize = sizeof(DEVMODE);
devMode->dmOrientation = DMORIENT_LANDSCAPE;
devMode->dmFields = DM_ORIENTATION;
::GlobalUnlock( devMode );
PrintDialog.m_pd.hDevMode = ::GlobalAlloc( GHND, sizeof(DEVMODE) );
DEVMODE * devMode = (DEVMODE *) ::GlobalLock( PrintDialog.m_pd.hDevMode );
devMode->dmSize = sizeof(DEVMODE);
devMode->dmOrientation = DMORIENT_LANDSCAPE;
devMode->dmFields = DM_ORIENTATION;
::GlobalUnlock( devMode );
Finally,this article will help you alot:
HOWTO: Modify Printer Settings with DocumentProperties()
http://support.microsoft.com/support/kb/articles/Q167/3/45.ASP
HOWTO: Modify Printer Settings with DocumentProperties()
http://support.microsoft.com/support/kb/articles/Q167/3/45.ASP
ASKER
For Wyn.
The first 7 lines of your 4.40 (first) answer did the trick wonderfully well.
Thanks, Mike Gordon.
The first 7 lines of your 4.40 (first) answer did the trick wonderfully well.
Thanks, Mike Gordon.
CPrintDialog PrintDialog(FALSE);
AfxGetApp()->GetPrinterDev
DEVMODE FAR *lpDevMode = (DEVMODE FAR *)
::GlobalLock(PrintDialog.m
//set mode
lpDevMode->dmOrientation = DMORIENT_LANDSCAPE;
::GlobalUnlock(PrintDialog
Then create a CDC and attach with PrinterDC:
CDC DC;
DC.Attach(PrintDialog.GetP
//Then set the document info
DOCINFO di;
CString strTitle;
memset (&di,0,sizeof(DOCINFO));
strTitle.LoadString (AFX_IDS_APP_TITLE);
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = strTitle;
strTitle.Empty();
//start the actual printing
DC.StartDoc (&di);
DC.StartPage ();
//printing here.....
DC.TextOut();
.......detach latter.
All..