-
December 31st, 2004, 11:22 AM
#1
Printer Paper Oritentation problem!
Hi,
I have a MFC app which conatians a chart control. I want to print this chart to the printer. I can do it using inbuilt properties for the chart but only in portrait mode.
Is there a way to set the orientation of the printer to landscape before is start printing. I don't know any interface or classes that provide such functionality.
Please Help!!!
-
December 31st, 2004, 12:51 PM
#2
Re: Printer Paper Oritentation problem!
The function shown below sets the orientation of the paper for a printer. Call this function before CView::OnFilePrint() and CView::OnFilePrintPreview() calls.
Code:
BOOL SetOrientation(BOOL bLandFl)
{
PRINTDLG pd;
pd.lStructSize=(DWORD)sizeof(PRINTDLG);
BOOL bRet=GetPrinterDeviceDefaults(&pd);
if(bRet)
{
// protect memory handle with ::GlobalLock and ::GlobalUnlock
DEVMODE FAR *pDevMode=(DEVMODE FAR *)::GlobalLock(m_hDevMode);
// set orientation to landscape
if(bLandFl)
pDevMode->dmOrientation=DMORIENT_LANDSCAPE;
else
pDevMode->dmOrientation=DMORIENT_PORTRAIT;
::GlobalUnlock(m_hDevMode);
}
else
{
CString s;
s.LoadString(IDS_STRING34116); //Failed to select the orientation of the paper for the printer
AfxMessageBox(s);
}
return bRet;
}
A.M.
My Latest Articles:
CCustomBitmapButton - An owner-draw button and a frame for the caption bar, in one class.
CCustomTabCtrl - A clone of the Excel tab sheet control.
-
December 31st, 2004, 03:59 PM
#3
Re: Printer Paper Oritentation problem!
I forgot to say that SetOrientation() function should be declared in your application class derrived from CWinApp. HGLOBAL m_hDevMode is protected member of the CWinApp class.
A.M.
My Latest Articles:
CCustomBitmapButton - An owner-draw button and a frame for the caption bar, in one class.
CCustomTabCtrl - A clone of the Excel tab sheet control.
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
|