Click here to Skip to main content
Licence CPOL
First Posted 19 Jun 2002
Views 90,846
Bookmarked 21 times

Example of how to print a long CString across multiple pages of output using the MFC print architecture

By | 19 Jun 2002 | Article
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 is 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 extercise using the CDC::DrawText()function.

I hope this example will help out beginners at printing.

Enjoy!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Roger Allen

Software Developer (Senior)
Sirius Analytical Instruments
United Kingdom United Kingdom

Member

A research and development programmer working for a pharmaceutical instrument company for the past 17 years.
 
I am one of those lucky people who enjoys his work and spends more time than he should either doing work or reseaching new stuff. I can also be found on playing DDO on the Cannith server (Send a tell to "Maetrim" who is my current main)
 
I am also a keep fit fanatic, doing cross country running and am seriously into [url]http://www.ryushinkan.co.uk/[/url] Karate at this time of my life, training from 4-6 times a week and recently achieved my 1st Dan after 6 years.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionThank u! Pinmembersally899822:38 21 Jun '11  
GeneralTechnical adaptation to a CEditView derived SDI application PinmemberRaymond_Gimilio20:35 8 Feb '10  
GeneralPage setup PinmemberTariqZ19:33 5 Jun '07  
GeneralFaster method (Great article Btw) PinmemberY_R9:55 1 Feb '07  
QuestionPage Breaks Using MFC 6.0+ Pinmemberomar639:27 14 Nov '06  
GeneralMultiple print job Pinmembervivadotnet11:59 12 Aug '04  
Generalconstructing long string... Pinmembervivadotnet6:01 8 Jul '04  
GeneralRe: constructing long string... PinsussAtewar10:44 22 Jul '04  
GeneralRe: constructing long string... Pinmembervivadotnet12:00 31 Jul '04  
GeneralCEditView and CString PinmemberThe_Inventor20:14 21 Jun '04  
GeneralRe: CEditView and CString Pinmembertom-kaltofen23:37 30 Jan '06  
GeneralWord Wrap PinmemberGerard Lim3:00 31 May '04  
Generalthanks a lot Pinmemberabicer22:06 27 Apr '04  
GeneralPrint question Pinmembernikoladsp6:19 13 Jan '04  
GeneralPrinting to a Printer/Help Pinmembermelshehu5:58 16 Oct '02  
GeneralRe: Printing to a Printer/Help PinmemberRoger Allen2:37 17 Oct '02  
GeneralRe: Printing to a Printer/Help Pinmembermelshehu5:54 17 Oct '02  
GeneralJust what I was looking for PinmemberDylan Kenneally1:17 24 Jul '02  
GeneralRe: Just what I was looking for PinmemberRoger Allen3:06 24 Jul '02  
GeneralGood job. PinmemberShog917:59 20 Jun '02  
GeneralRe: Good job. PinmemberRoger Allen22:47 20 Jun '02  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 20 Jun 2002
Article Copyright 2002 by Roger Allen
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid