Solved

Switching Paper Orientation Programmatically

Posted on 1997-06-29
4
309 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
ID: 1399587
Use CPrintDialog::CreatePrinterDC method to do what you want.
0
 

Author Comment

by:scce
ID: 1399588
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
ID: 1399589
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
ID: 1399590
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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 shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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