Solved

Switching Paper Orientation Programmatically

Posted on 1997-06-29
4
298 Views
Last Modified: 2013-12-03
I need to be able to store the most recently used paper orientation from the last app session and restore it the next  time the program is run.  Storing it is no problem, but I can't work out how to do the switch.  

I'm using MFC 2.5 which handles all printer settings thorugh CPrintDlg (a wrapper for the PRINTDLG structure).  Any changes the user makes are hidden away inside the common print dialog procedure, so there's no clues there.  Simply modifying the DEVMODE structure (stored by CWinApp) causes system errors, so I assume the update must be done within a Windows function.

The solution needs to be compatible with the MFC 2.5 printing framework.  Any suggestions?  Thanks.
0
Comment
Question by:scce
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
AVaulin earned 100 total points
Comment Utility
Use CPrintDialog::CreatePrinterDC method to do what you want.
0
 

Author Comment

by:scce
Comment Utility
I'm not sure what you mean, AVaulin.  How do I use the CreatePrinterDC function and then manipulate it to change settings?  Can you provide a little more detail?

Thanks.
0
 
LVL 4

Expert Comment

by:AVaulin
Comment Utility
You said "Storing it is no problem". To restore you must use CreatePrinterDC method of CPrintDialog class. You must construct CPrintDialog object and call CreatePrinterDC method without calling DoModal function. Set all parameters you need in m_psd class member (it's PAGESETUPDLG public CCommonDialog class member and CPrintDialog is CCommonDialog son).
Good luck.
0
 

Author Comment

by:scce
Comment Utility
Thanks, AVaulin.

I'm not sure if this will work for me though, because I am using MFC 2.5 (16-bit) - isn't CCommonDialog and PAGESETUPDLG new for 32-bit MFC?

Anyway I will try to find the equivalent fields for the PRINTDLG structure and use the CreatePrinterDC function as you suggested.

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

8 Experts available now in Live!

Get 1:1 Help Now