Solved

Setting Paper size within Win32 MFC program

Posted on 1997-07-06
1
375 Views
Last Modified: 2013-12-03
The documented SetDocumentProperties() API does not seem to work as stated.  I am writing a program that needs to print to a pre-printed form that is a strange size (205 mm X 433 mm).  According to Microsoft I can use the DM_PAPERLENGTH and DM_PAPERWIDTH in the DEVMODE structure to set the paper size to any size I need (specified in .1 mm units).  Unfortunately this doesn't seem to be supported by all drivers (some dot-matrix printers I tested didn't work).  Is there a better way to specify odd sized paper within an MFC program?

Thanks.
0
Comment
Question by:bbishop
[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
1 Comment
 
LVL 4

Accepted Solution

by:
tflai earned 100 total points
ID: 1400213
I have an easy solution that I did to imitate the effect of
an user changing printer setting.  It was for MSVC 1.5, but
I think it should also work for you.

      CPrintDialog pd(TRUE);
      CWinApp::UpdatePrinterSelection(FALSE);
      pd.m_pd.hDevMode = m_hDevMode;
      LPDEVMODE DevMode = pd.GetDevMode();      
      DevMode->dmOrientation = DMORIENT_LANDSCAPE;

Here, I make my MSVC application to start out with
landscape orientation regardless of what the
default printer setting is.  And for printer paper
size or other options, just change the other fields
of DEVMODE structure.
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

738 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