The study of chapter 13 in programming windows with mfc-printing with document and views
来源:互联网 发布:阿里云服务器退款 编辑:程序博客网 时间:2024/04/28 06:24
1.The base architecture:
CDC dc(this);
CPrintDialog dlg(False);
//dlg.GetDefault();
//if(dlg.DoModal()==IDOK)
dc.Attach(dlg.GetPrintDC())
DOCINFO di;
::ZeroMemory(&di,sizeof(DOCINFO));
di.cbSize=sizeof(DOCINFO)
di.lpszDocName=_T("ddddddddd");
if(dc.StatDoc(&di))
int nContinue=true;
for(int i=0;i<nPage&&nContinue;i++)
{
dc.StartPage();
//
if(dc.EndPage()<0)
nContinue=false;
}
if(nContinue)
dc.EndDoc();
else
dc.Abort();
2.Abort processure:[CView]
int CALLBACK AbortProc(HDC hDC,UNIT nCode)
{
MSG msg;
while(!bUserAbort&&::PeekMessage(&msg,0,0,PM_NOREMOVE)
AfxGetThread()->PumpMessage();
return !bUserAbort;
}
3.MFC print Architecture
OnPreparePrinting(CDC *pDC,CPrintInfo *pf)
{
pf->SetMaxPage(3);
return DoPreparePrinting(pDC,pf);
}
OnBeginPrinting(CDC *pDC,CPrintInfo *pf)
{
int nPageHeight=pf->GetDeviceCaps(VERTRES);
int nDocLength=pf->GetDocLength();
int nMaxPage=max(1,(nDocLength+nPageHeight-1)/nPageHeight);
pf->SetMaxPage(nMaxPage);
}
If it's impossible (or simply inconvenient) to determine the document length before printing begins, you can perform print-time pagination by overriding OnPrepareDC and setting CPrintInfo::m_bContinuePrinting to TRUE or FALSE each time OnPrepareDC is called. An m_bContinuePrinting value equal to FALSE terminates the print job. If you don't call SetMaxPage, the framework assumes the document is only one page long. Therefore, you must override OnPrepareDC and set m_bContinuePrinting to print documents that are more than one page long if you don't set the maximum page number with SetMaxPage.
OnPrepareDC(CDC *pDC,CPrintInfo *pf) //you need to override OnPrepareDC only if you use OnDraw to draw to both the screen and the printed page.
{
CView::OnPrepareDC(pDC,pf);
if(pDC->isPrinting())
{
//.........
int y=(pf->m_nCurPage-1)/nPageHeight;
pDC->SetViewOrg(0,-y);
}
}
OnPrint(CDC *pDC,CPrintInfo *pf) //It's usually more practical to put printer output logic in OnPrint and screen logic in OnDraw.
{
PrintHeader(pDC);
PrintPageNumber(pDC,pf->m_nCurPage);
// Set the viewport origin and/or clipping region before
OnDraw(pDC);
}
OnEndPrinting(CDC *pDC,CPrintInfo *pf)
4.PrintPreview
CView::OnFilePrintPreview ID=ID_FILE_PRINT_PREVIEW
void CMyView::OnEndPrintPreview (CDC* pDC, CPrintInfo* pInfo, POINT point, CPreviewView* pView) { UINT nPage = pInfo->m_nCurPage; POINT pt; // Convert nPage into a scroll position in pt. ScrollToPosition (pt); CScrollView::OnEndPrintPreview (pDC, pInfo, point, pView); }
- The study of chapter 13 in programming windows with mfc-printing with document and views
- The study of Programming Windows with MFC-printing tips
- The Study of Programming Windows with MFC--Imagelist and ComboBoxEx
- The study of Programming Windows with MFC
- The study of Programming Windows with MFC--print's example
- The study of Programming Windows with MFC-Palette
- The study of Programming Windows with MFC--BitMap
- The Study of Programming Windows with MFC--Bitmap2
- The study of Programming Windows with MFC--CRgn
- The study of Programming Windows with MFC--Common Control
- The Study of Programming Windows with MFC--Slider,Spin,ToolTip
- The Study of Programming Windows with MFC--Progress and Animate control
- The study of Programming Windows with MFC--Ip Address control and Date control
- Printing with Documents and Views
- Programming Windows with MFC - Capter 10. Scroll Views, HTML Views, and Other View Types
- the study of programmng windows with mfc--timer
- Programming Windows with MFC - Chapter 12 Toolbars
- programming windows with MFC
- 转windows 开始--运行命令大全
- MFC CListCtrl的用法.Style/插入、删除、选中数据及排序问题等
- C#串口通信时丢失数据的一种解决方法
- 用WWW-Authenticate实现登录验证
- 无线网络性能测试标准
- The study of chapter 13 in programming windows with mfc-printing with document and views
- WebKit移植分析之一
- 软件
- 应用内存溢出 --ASP.NET
- JUnit4学习小结
- ubuntu下配置python开发环境(Eclipese+Pydev)
- 关于mysql index length
- TUP第二期 Web2.0沙龙活动:实时搜索技术揭秘
- Windows Installer Cleanup下载安装和使用方法