[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Setting Paper size within Win32 MFC program

Posted on 1997-07-06
1
Medium Priority
?
385 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 300 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

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 …
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

829 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