Solved

Setting Paper size within Win32 MFC program

Posted on 1997-07-06
1
356 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 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

14 Experts available now in Live!

Get 1:1 Help Now