Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change paper orientation?

Status
Not open for further replies.

mirr2001

Programmer
Mar 29, 2002
24
DK
I am desperately trying to change the page setup, so that the paper will get landscape orientation.
Is there any simple way to achieve this in MSVC? I have already searched the MSDN database, and I only got the solutions to change the DEVMODE structure, but in order to do this, you seem to have to know a bit about memory-management (like GlobalUnlock- functions etc.).

I would be grateful for any suggestions
 
I remember doing the same thing once, and I don't recall using the GlobalUnlock function. As far as I remember, all you have to do is get the DEVMODE structure for the printer (I believe CPrintDC has a member function called GetDevMode() for this purpose), modify the members you need, and set it back. After you set the new properties, however, you need to call ResetDC() for the changes to take effect.

HTH
 
I have tried it your way, but it didn't really work.
But although I found a quite simple solution (which included GlobalLock and GlobalUnlock):
In the InitInstance() from CMyApp I added this after
"CWinApp::InitInstance()" :
PRINTDLG pDdlg;
Code:
PRINTDLG pDdlg;
if(AfxGetApp()->GetPrinterDeviceDefaults(&pDdlg))
{
	DEVMODE *mode = (DEVMODE *) GlobalLock(pDdlg.hDevMode);
	mode->dmOrientation = DMORIENT_LANDSCAPE;
	GlobalUnlock(pDdlg.hDevMode);
		AfxGetApp()->SelectPrinter(pDdlg.hDevNames,pDdlg.hDevMode,FALSE);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top