Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Forcing landscape orientation

Posted on 2000-03-18
5
Medium Priority
?
434 Views
Last Modified: 2013-11-20
How can I force Print Preview  to show a particular view in landscape orientation without user intervention?
(and Print to print it, naturally!)
Mike.
0
Comment
Question by:mgordon
  • 4
5 Comments
 
LVL 5

Accepted Solution

by:
Wyn earned 400 total points
ID: 2632625
Dllocate a device mode structure (DEVMODE) and indicate that the dvice is in landscape mode.
Print is just working with a print DC in the same way.

Continue.
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2632649
If you use MFC ,Use a CPrintDialog:

CPrintDialog PrintDialog(FALSE);
   
 
AfxGetApp()->GetPrinterDeviceDefaults(&PrintDialog.m_pd);

DEVMODE  FAR *lpDevMode  = (DEVMODE  FAR *)  
::GlobalLock(PrintDialog.m_pd.hDevMode);
//set mode
lpDevMode->dmOrientation = DMORIENT_LANDSCAPE;
 
::GlobalUnlock(PrintDialog.m_pd.hDevMode);

Then create a CDC and attach with PrinterDC:
  CDC DC;
  DC.Attach(PrintDialog.GetPrinterDC());
 
//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..
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2632658
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 );  
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2632677
Finally,this article will help you alot:

HOWTO: Modify Printer Settings with DocumentProperties()
http://support.microsoft.com/support/kb/articles/Q167/3/45.ASP
0
 

Author Comment

by:mgordon
ID: 2639348
For Wyn.
The first 7 lines of your 4.40 (first) answer did the trick wonderfully well.
Thanks, Mike Gordon.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question