Link to home
Start Free TrialLog in
Avatar of scce
scce

asked on

Switching Paper Orientation Programmatically

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.
ASKER CERTIFIED SOLUTION
Avatar of AVaulin
AVaulin
Flag of Ukraine image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of scce
scce

ASKER

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.
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.
Avatar of scce

ASKER

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.