CView::OnPreparePrinting
http://technet.microsoft.com/zh-cn/subscriptions/a59dff1e(v=vs.71).aspx
CView::OnPreparePrinting
Called by the framework before a document is printed or previewed.
virtual BOOL OnPreparePrinting(
CPrintInfo* pInfo
);
Parameters
pInfo
Points to a CPrintInfo structure that describes the current print job.
Return Value
Nonzero to begin printing; 0 if the print job has been canceled.
Remarks
The default implementation does nothing.
You must override this function to enable printing and print preview. Call the DoPreparePrinting member function, passing it the pInfo parameter, and then return its return value; DoPreparePrinting displays the Print dialog box and creates a printer device context. If you want to initialize the Print dialog box with values other than the defaults, assign values to the members of pInfo. For example, if you know the length of the document, pass the value to the SetMaxPage member function of pInfo before calling DoPreparePrinting. This value is displayed in the To: box in the Range portion of the Print dialog box.
DoPreparePrinting does not display the Print dialog box for a preview job. If you want to bypass the Print dialog box for a print job, check that the m_bPreview member of pInfo is FALSE and then set it to TRUE before passing it to DoPreparePrinting; reset it to FALSE afterwards.
If you need to perform initializations that require access to the CDC object representing the printer device context (for example, if you need to know the page size before specifying the length of the document), override the OnBeginPrinting member function.
If you want to set the value of the m_nNumPreviewPages or m_strPageDesc members of the pInfo parameter, do so after calling DoPreparePrinting. The DoPreparePrinting member function sets m_nNumPreviewPages to the value found in the application's .INI file and sets m_strPageDesc to its default value.
Example
Override OnPreparePrinting and call DoPreparePrinting from the override so that the framework will display a Print dialog box and create a printer DC for you.
BOOL CMyView::OnPreparePrinting(CPrintInfo *pInfo)
{
return CEditView::DoPreparePrinting(pInfo);
}
If you know how many pages the document contains, set the maximum page in OnPreparePrinting before calling DoPreparePrinting. The framework will display the maximum page number in the "to" box of the Print dialog box.
BOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo)
{
//The document has 2 pages.
pInfo->SetMaxPage(2);
return CEditView::DoPreparePrinting(pInfo);
CView::OnPreparePrinting的更多相关文章
- 深入浅MFC
视图类CView 在MFC"文档/视图"架构中,CView类是所有视图类的基类,它提供了用户自定义视图类的公共接口.在"文档/视图"架构中,文档负责管理和维护数 ...
- MFC Wizard创建的空应用程序中各个文件内容的解析
创建的MFC应用程序名为:wd,那么: 一.wd.h解析 // wd.h : main header file for the WD application // #if !defined(AFX_W ...
- MFC CVIew关闭时崩溃
记得看视频的时候老师说过 创建CView的时候,也就是创建视图的时候,不要使用 Cview m_view;这种方式 而是使用Cview * pView=new Cview() ...
- CView类的使用
首先我们来写一个样例: 1.建一个win32简单应用程序,不要觉得这样就不能写出MFC程序,由于是不是MFC程序取决于调没调MFC函数. 2. 删除入口函数.仅仅留下#include "st ...
- MFC修改视图CView的背景颜色
(1) 在CYournameView(就是你的视图类,以下以CDrawLineView为例)添加了一个背景颜色变量 COLORREF m_bgcolor; (2)修改这个函数: BOOL CDrawL ...
- CWinApp类CMultiDocTemplate类CDocument类CView类的关系
转自:http://blog.csdn.net/bboot/article/details/26884011 不得不转,瞬间搞清了很多问题,短小精悍 1.CWinApp类 它包含并管理着应用程序的 ...
- MFC覆盖OnPrepareDC实现“所见即所得”打印
附件下载:http://files.cnblogs.com/mengdejun/print.zip void CPrintView::OnPrepareDC(CDC* pDC, CPrintInfo* ...
- 魔改——MFC SDI 支持 内嵌 EXCEL OLE
==================================声明================================== 本文版权归作者所有 未经作者授权 请勿转载 保留法律追究的 ...
- 积累的VC编程小技巧之打印相关
1.修改打印预览的ToolBar 为AFX_IDD_PREVIEW_TOOLBAR这个ID创建一个DialogBar.则系统就会用新创建的DialogBar代替系统默认的那个 2.关于打印 1.要打印 ...
随机推荐
- SQL一列的合并连起来
CREATE TABLE #temp( ID INT, name NVARCHAR(max), age int, address ) ) insert into #temp select ID, na ...
- ajax处理错误(六)
使用ajax时必须留心两类错误,他们之间的区别源于视角不同. 一.第一类错误是从XMLHttpRequest对象的角度看到的问题:某些因素阻例如止了请求发送到服务器,例如DNS无法解析主机名,连接请求 ...
- mini vimrc
Mini version: set enc=utf-8 ffs=unix,dos,mac lm=zh_CN.utf-8 set nu nowb nocp nowrap ru nobk sm is no ...
- 原生js模拟jquery中的addClass和removeClass方法
js代码: //添加类 function addClass(obj,className) { if(obj.className == '') { //如果没有class obj.className = ...
- 本地用户 vsftpd 配置文件
# 禁止匿名用户anonymous登录 anonymous_enable=NO # 允许本地用户登录 local_enable=YES local_root=/data/wwwroot/ # 让登录的 ...
- 判断控件的CGRect是否重合,获取控件的最大XY值
判断给定的点是否被一个CGRect包含: BOOL contains = CGRectContainsPoint(CGRect rect, CGPoint point); 判断一个CGRect是否和另 ...
- javascript——对象
分类 JavaScript对象分类: 内置对象:由ECMAScript规范定义的对象或类,例如:数组.函数.日期(Date()).正则表达式 宿主对象:是由js解释器所嵌入的宿主环境(比如Web浏览器 ...
- Top 22 Free Responsive HTML5 Admin & Dashboard Templates 2018
Top 22 Free Responsive HTML5 Admin & Dashboard Templates 2018 May 18, 2018 Alex Ivanovs Website ...
- View State
如何查看viewstate 鼠标右键页面,然后view page source 源码中搜索viewstate,会找到一个隐藏的字段. <input type="hidden" ...
- Flat UI简介
Flat UI简介 一.简介 Flat UI是基于Bootstrap之上进行二次开发的扁平化前端框架,他提供了动感.时尚的风格色调搭配,简洁.炫丽的功能组件,同时还提供了更为平滑的js交互动画,可以称 ...