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.要打印 ...
随机推荐
- [Usaco2009 Feb]Stock Market 股票市场 完全背包
Code: #include<cstdio> #include<algorithm> #include<iostream> #include<cstring& ...
- Codeforces Round #206 (Div. 2) 部分题解
传送门:http://codeforces.com/contest/355 A:水题,特判0 int k,d; int main(){ //FIN; while(cin>>k>> ...
- 【Docker端口映射】
Docker端口映射即将容器内开放的端口映射到宿主机端口,以实现外部网络的访问. 首先,我们先下载用于测试端口映射的镜像: [root@fedora ~]# docker pull training/ ...
- make---GNU编译工具
make命令是GNU的工程化编译工具,用于编译众多相互关联的源代码问价,以实现工程化的管理,提高开发效率. 知识扩展 无论是在linux 还是在Unix环境 中,make都是一个非常重要的编译命令.不 ...
- CCF模拟题 最优配餐
最优配餐 时间限制: 1.0s 内存限制: 256.0MB 问题描述 栋栋最近开了一家餐饮连锁店,提供外卖服务.随着连锁店越来越多,怎么合理的给客户送餐成为了一个急需解决的问题. 栋栋的连锁店所在 ...
- [Python] Python list slice syntax fun
# Python's list slice syntax can be used without indices # for a few fun and useful things: # You ca ...
- Mysql第八天 分区与分表
分区表 主要提供例如以下的特性,或者适合如此场景: 数据量非常大, 或者仅仅有表中最后的部分有热点数据.其它均为历史数据 分区表数据更easy维护,能够对独立的分区删除等操作 分区表的数据能够分布在不 ...
- Reuse Is About People and Education, Not Just Architecture
 Reuse Is About People and Education, Not Just Architecture Jeremy Meyer you MigHT AdopT THE AppRoA ...
- es62
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- POJ 3040 贪心
贪心好题 ---. 思路: 从大到小凑C 如果不够 再从小到大补满(超过)C //By SiriusRen #include <cstdio> #include <cstring&g ...