Solved

Forcing landscape orientation

Posted on 2000-03-18
5
426 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 100 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 96
set up trigger (or something) to rename files (starting with ATL) in a linux directory 6 55
Detect CR LF to each line 12 171
Problem to App source 6 75
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: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

830 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