文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 计算机软件及应用 > MFC打印与打印预览(1)
侵权投诉

MFC打印与打印预览(1)

MFC打印与打印预览(1)

Programming Windows 95 with MFC, Part VIII: Printing and Print Previewing

Jeff Prosise

Jeff Prosise writes extensively about programming in Windows and is a contributing editor of

several computer magazines. He is currently working on a book, Programming Windows 95 with MFC, to

be published this spring by Microsoft Press.

Click to open or copy the EZPRNT project files.

Click to open or copy the HEXDUMP project files.

I demonstrated previously ("Programming Windows® 95 with MFC, Part VII: The Document/View Architecture," MSJ, February 1996) how the document/view architecture simplifies the development of SDI and MDI applications by letting the framework take over key aspects of a program's operation. Now I'll show you how the same document/view architecture simplifies printing and print previewing. Even MFC-style printing isn't something to be taken lightly, but thanks to the support lent by the framework, the tedium of writing and testing code that renders documents on printers and other hardcopy devices is

sharply reduced. And once you've implemented Print, Print Preview comes almost for free.

Documents and Views

The MFC print architecture is built around core API print functions and protocols built into the

Windows GDI. To understand what's on the outside, it helps to first understand what's on the inside. In

this article I will:

Discuss the Windows printing model and examine the steps an SDK-style application goes through to

print a document.

Describe the relationship between the MFC print architecture and the Windows print architecture, and the mechanics of printing from MFC applications, including key virtual functions you can override in your

view class.

Develop a bare-bones printing program that demonstrates how the same code can be used to send

output to the screen or printer.

Develop a more ambitious program with print and preview capabilities on par with those of

commercial applications. (Sounds pretty good, huh?)

The Windows Print Architecture

Printing a document from a Windows-based application without the benefit of the framework

involves a number of grueling steps. The application normally begins by obtaining a device context for the printer. Just as you need a screen DC to send output to the screen, you need a printer DC to send output to a printer. If you know the device name of the printer you want, you can create a device context

with the ::CreateDC function in Windows or CDC::CreateDC in MFC.

第1页

你可能喜欢

热门文档

相关文档

  • mfc打印功能的实现

    //Required for printing ON_COMMAND(ID_FILE_PRINT,CView::OnFilePrint) END_MESSAGE_MAP() 准备打印 为了对 MFC 应用程序的打印及打印预览提供支持,仅有一个...

  • 使用MFC编写打印程序

    本文首先介绍了利用MFC提供的文档视图框架来实现一个打印程序,实现打印预览,在此基础上,同时通过对 MFC源代码的深入探讨,提出了利用该方法在对话框上用MFC实现打印...

  • 08 打印和打印预览

    打印和打 印预览功能是必不可少的。MFC 通过 CView 类提供文档的打印与打印预览功能。主要讲述 Visual C++ 中关于打印和打印预览的知识。主要涉及 Windows API ...

  • vc 打印预览

    vc 打印预览_IT/计算机_专业资料。打印预览VC++对话框程序打印及打印预览的实现 VC++对话框程序打印及打印预览的实现摘要: MFC 文档/视图的应用程序,向导给了...

  • 第8章 打印和打印预览

    打印和打印预览功能是必不 可少的。 通过CView类提供文档的打印与打印预览功 可少的。MFC通过 通过 类提供文档的打印与打印预览功 本章主要讲述Visual C++中关于...

  • 在VC对话框中实现打印和打印预览

    1 实现打印 在对话框应用程序中不具备 MFC 的视和框架交互,要想实现打印和打印预览必须直接获取打印机的设备环境句柄,这时可以设置 CPringDialog 类中的构造函数的...

  • MFC打印程序

    MFC打印程序_计算机软件及应用_IT/计算机_专业资料。在 MFC 下实现打印步骤: ...。 先看下打印预览的效果吧: 下面再解释下实现的代码: intnWidth=pDC->Get...

  • VC++对话框程序打印及打印预览的实现

    VC++对话框程序打印及打印预览的实现_IT/计算机_专业资料。VC++MFC 对话框程序打印及打印预览的实现系统介绍了对话框打印程序机制,以及如何实现!...

  • 打印和打印预览

    为了实现打印和打印预览功能,首先需要了解 MFC 的打印体系结构,即框架是如何处 理打印文档的要求的。 MFC 的打印工作大致上是这样进行的: 1.显示 Print 对话框 ...

  • 在VC6.0对话框应用程序中实现打印和打印预览

    一、 实现打印 在对话框应用程序中不具备 MFC 的视和框架交互,要想实现打印和打印预览必须直接获取 打印机的设备环境句柄,这时可以设置 CPringDialog 类中的构造...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email