CPrintDlg to appear with Landscape printing orientation
来源:互联网 发布:ug mac pro 编辑:程序博客网 时间:2024/05/21 18:12
Trying to get a CPrintDlg to appear with Landscape printing orientation
selected by default. I have tried to allocate a DEVMODE structure and fill
it but this did not work.
void ReportPrinter::PrintReport( BOOL bPrintLandscape )
{
HDC hdcPrn;
HANDLE hDevMode;
LPDEVMODE lpDevMode;
// Instantiate a CPrintDialog.
CPrintDialog *i_printDlg =
new CPrintDialog( FALSE, PD_ALLPAGES | PD_RETURNDC | PD_NOSELECTION
/*| PD_PRINTSETUP */| PD_RETURNDEFAULT, NULL );
// Get the default printer settings using the PD_RETURNDEFAULT flag.
PrintDlg( &( i_printDlg->m_pd ) );
hDevMode = i_printDlg->m_pd.hDevMode;
// Clear the PD_RETURNDEFAULT flag; we'll set flags to our preferences below
i_printDlg->m_pd.Flags &= ~( PD_RETURNDEFAULT );
if ( TRUE == bPrintLandscape )
{
// Set print orientation to 'Landscape'.
lpDevMode = (LPDEVMODE)GlobalLock( hDevMode );
lpDevMode->dmFields = DM_ORIENTATION;
lpDevMode->dmOrientation = DMORIENT_LANDSCAPE;
GlobalUnlock( hDevMode );
}
// Initialize some of the fields in PRINTDLG structure.
i_printDlg->m_pd.nMinPage = i_printDlg->m_pd.nMaxPage = 1;
i_printDlg->m_pd.nFromPage = i_printDlg->m_pd.nToPage = 1;
// Display Windows print dialog box.
if ( IDOK == i_printDlg->DoModal() )
{
// Obtain a handle to the device context.
hdcPrn = i_printDlg->GetPrinterDC();
if ( hdcPrn != NULL )
{
m_pDC = new CDC;
m_pDC->Attach( hdcPrn ); // attach a i_printer DC
m_pDC->StartDoc( m_strReportID.c_str() ); // begin a new i_print job
CalcPageSize( hdcPrn ); // Set the i_printing alignment
while ( m_bMoreData )
{
m_nPrinterYPos = 0;
m_pDC->StartPage(); // begin a new page
m_bMoreData = WriteReport(); // write a page
m_pDC->EndPage(); // end a page
}
m_pDC->EndDoc(); // end a i_print job
m_pDC->Detach(); // detach the i_printer DC
delete m_pDC;
}
}
delete i_printDlg;
}
- CPrintDlg to appear with Landscape printing orientation
- Force IOS 6 force device orientation to landscape
- how to automate label printing with command line parameters
- Printing with Style
- Printing with String Literals
- To do beautiful printing
- Converting the app to landscape
- how to set Crystal Report options with printing preferences Dialog in C#
- Printing with Documents and Views
- PRINTING IN LINUX WITH CUPS
- Correct Smartphone Video Orientation and How To Rotate iOS and Android Videos with ffmpeg
- text to ps for printing
- Solution to Printing Neatly Problem
- [Code Snip]Turn To Landscape mode
- Printing ALV along with Page numbers
- How to Use Excel VBA for Printing
- Android VideoView orientation change with buffered video
- Changing Android Device orientation with ADB
- 类的the big three原则
- Quora’s Technology Examined
- 论文格式
- 手机腾讯,神兽精武游戏代挂
- ibatis学习笔记(四)>>>>>>>ibatis使用实例
- CPrintDlg to appear with Landscape printing orientation
- GProfile的总结
- 【转】s3c6410 framebuffer分析
- aix 文件大小限制
- .net访问Oracle数据库——数据库连接
- 造纸行业仍处于“去库存”阶段
- Windows下cvs安装配置
- c/c++标准预定义宏
- compiler error output to a file named err