Solved

Forcing landscape orientation

Posted on 2000-03-18
5
424 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
For Wyn.
The first 7 lines of your 4.40 (first) answer did the trick wonderfully well.
Thanks, Mike Gordon.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ADO Memory leak with DELPHI 2007 37 153
xyBalance chalenge 58 88
Host to IP 7 73
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 79
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now