65.9K
CodeProject is changing. Read more.
Home

Example of How to Print a Long CString across Multiple Pages of Output using the MFC Print Architecture

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.50/5 (9 votes)

Jun 20, 2002

CPOL
viewsIcon

129279

downloadIcon

2388

An example project of how to break up a long string that you want to print across multiple pages

Sample Image - Preview.jpg

Introduction

A common question in the forums in the past has been how do I break up a long string and print it using the standard MFC architecture. Above is an example project that does just that. You can enter a long string to print in a MultiLine edit control. To see what the output would be like for your printer, you can select the Print Preview option from the file menu.

There are some drawbacks in the example in that it doesn't handle tabs correctly as it only uses CDC::TextOut() when printing, and CDC::GetTextExtent() when measuring whether the currently selected line will fit in one line, or needs to be broken up across multiple lines. This can be changed by yourselves as a programming exercise using the CDC::DrawText() function.

I hope this example will help out beginners at printing.

Enjoy!