?
Solved

Forcing landscape orientation

Posted on 2000-03-18
5
Medium Priority
?
430 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month13 days, 20 hours left to enroll

801 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