|
-
August 12th, 2004, 10:50 AM
#1
A good way to Change the printer to landscape!
I think the following code maybe very useful to some one of you to change the printer to landscape:
Code:
void CMyApp::SetLandscape()
{
LPDEVNAMES lpDevNames;
LPTSTR lpszDriverName, lpszDeviceName, lpszPortName;
HANDLE hPrinter;
PRINTDLG pd;
// Get default printer settings. PRINTDLG pd;
pd.lStructSize = (DWORD) sizeof(PRINTDLG);
if (GetPrinterDeviceDefaults(&pd))
{ // Lock memory handle.
DEVMODE FAR* pDevMode = (DEVMODE FAR*)::GlobalLock(m_hDevMode);
if (pDevMode)
{
// Change printer settings in here.
pDevMode->dmOrientation = DMORIENT_LANDSCAPE;
// Unlock memory handle.
lpDevNames = (LPDEVNAMES)GlobalLock(pd.hDevNames);
lpszDriverName = (LPTSTR )lpDevNames + lpDevNames->wDriverOffset;
lpszDeviceName = (LPTSTR )lpDevNames + lpDevNames->wDeviceOffset;
lpszPortName = (LPTSTR )lpDevNames + lpDevNames->wOutputOffset;
::OpenPrinter(lpszDeviceName, &hPrinter, NULL);
::DocumentProperties(NULL,hPrinter,lpszDeviceName,pDevMode,
pDevMode, DM_IN_BUFFER|DM_OUT_BUFFER);
// Sync the pDevMode.
// See SDK help for DocumentProperties for more info.
::ClosePrinter(hPrinter);
::GlobalUnlock(m_hDevNames);
::GlobalUnlock(m_hDevMode);
}
}
}
Regards
Jack
------------------------------------------------------------------------------
XD++ MFC Library with 100% source code home : http://www.********.net
-
August 12th, 2004, 02:03 PM
#2
?
What is m_hDevNames and m_hDevMode in the code, I am trying use this code in a dialog based application by the way.
Thnaks !
Pauli
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|