Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Switching Paper Orientation Programmatically

Posted on 1997-06-29
4
Medium Priority
?
315 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 300 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

772 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