The study of Programming Windows with MFC-printing tips
2010-07-31 09:40
519 查看
Using the Print Dialog's Selection Button
pInfo->m_pPD->m_pd.Flags&~PD_NOSELECTED
pInfo->m_pPD->m_pd.Flags|PD_SELECTED
(PRINTDLG CPrintDialog::m_pd )
Adding Default Pagination Support
CSIZE size;
CPrintInfo pi;
if(AfxGetApp()->GetPrinterDeviceDefault(&pi.m_pPD->m_pd))
{
HDC hDC=pi.m_pPD->m_pd;
if(hDC==NULL)
hDC=pi.m_pPD->CreatePrinterDC();
else
{
CDC dc;
dc.Attach(hDC);
size.cx=dc.GetDeviceCaps(HORZRES);
size.cy=dc.GetDeviceCaps(VERTRES);
::DeleteDC(dc.Detach());
}
}
Enumerating Printers
#include<winspool.h>
…
DWORD dwSize,dwPrinter;
::EnumPrinters(PRINT_ENUM_LOCAL,NULL,5,NULL,0,&dwSize,&dwPrinter);
BYTE *pBuffer=new BYTE[dwSize];
::EnumPrinters(PRINT_ENUM_LOCAL,NULL,5,pBuffer,dwSize,&dwSize,&dwPrinter);
if(dwPrinter!=0)
{
PRINTER_INFO_5 *pPrinter=(PRINTER_INFO_5*)pBuffer; // in Windows NT or Windows 2000, use PRINTER_INFO_4 structures instead
for(DWORD i=0;i<dwPrinter;i++)
{
pComboBox->addString(i,pPrinter->pPrinterName);
pPrinter++;
}
}
…
//a printer selected from combobox and create printerdc
CString nStrPrinterName;
int nIndex=pComboBox->GetCurSel();
pComboBox->GetLBText(nIndex,nStrPrinterName);
CDC dc;
dc.CreateDC(NULL,nStrPrinterName,NULL,NULL);
pInfo->m_pPD->m_pd.Flags&~PD_NOSELECTED
pInfo->m_pPD->m_pd.Flags|PD_SELECTED
(PRINTDLG CPrintDialog::m_pd )
Adding Default Pagination Support
CSIZE size;
CPrintInfo pi;
if(AfxGetApp()->GetPrinterDeviceDefault(&pi.m_pPD->m_pd))
{
HDC hDC=pi.m_pPD->m_pd;
if(hDC==NULL)
hDC=pi.m_pPD->CreatePrinterDC();
else
{
CDC dc;
dc.Attach(hDC);
size.cx=dc.GetDeviceCaps(HORZRES);
size.cy=dc.GetDeviceCaps(VERTRES);
::DeleteDC(dc.Detach());
}
}
Enumerating Printers
#include<winspool.h>
…
DWORD dwSize,dwPrinter;
::EnumPrinters(PRINT_ENUM_LOCAL,NULL,5,NULL,0,&dwSize,&dwPrinter);
BYTE *pBuffer=new BYTE[dwSize];
::EnumPrinters(PRINT_ENUM_LOCAL,NULL,5,pBuffer,dwSize,&dwSize,&dwPrinter);
if(dwPrinter!=0)
{
PRINTER_INFO_5 *pPrinter=(PRINTER_INFO_5*)pBuffer; // in Windows NT or Windows 2000, use PRINTER_INFO_4 structures instead
for(DWORD i=0;i<dwPrinter;i++)
{
pComboBox->addString(i,pPrinter->pPrinterName);
pPrinter++;
}
}
…
//a printer selected from combobox and create printerdc
CString nStrPrinterName;
int nIndex=pComboBox->GetCurSel();
pComboBox->GetLBText(nIndex,nStrPrinterName);
CDC dc;
dc.CreateDC(NULL,nStrPrinterName,NULL,NULL);
相关文章推荐
- The Study of Programming Windows with MFC--Slider,Spin,ToolTip
- The study of chapter 13 in programming windows with mfc-printing with document and views
- The Study of Programming Windows with MFC--Progress and Animate control
- The study of Programming Windows with MFC-Palette
- The Study of Programming Windows with MFC--Bitmap2
- The study of Programming Windows with MFC--BitMap
- The study of Programming Windows with MFC--Ip Address control and Date control
- The study of Programming Windows with MFC--print's example
- The study of Programming Windows with MFC--Common Control
- The Study of Programming Windows with MFC--Imagelist and ComboBoxEx
- The study of Programming Windows with MFC--CRgn
- The study of Programming Windows with MFC
- the study of programmng windows with mfc--timer
- Programming Windows with MFC - Capter 10. Scroll Views, HTML Views, and Other View Types
- Professional WPF Programming: .NET Development with the Windows Presentation Foundation
- Programming Windows with MFC - Capter 3. Mouse and keybord
- The Essence of Object-Oriented Programming with Java and UML
- Improve the Design and Flexibility of Your Project with Extreme Programming Techniques(Reship)
- Tricks of the Windows Game Programming Gurus,比较古老但是值得读的书[mikespook &amp; swill]
- Tricks of the Windows game programming gurus