Solved

Setting Paper size within Win32 MFC program

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

717 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