views:

337

answers:

5

I have developed my own Report Control which is simply nothing but drawing text on a CDC of the control window's client DC. I have got the printing function to work too. The report output is sent to the printer directly. However I want to let the user know the output before the report is actually printed.

I cannot do this using MFC's print preview architecture as my project is not using the doc/view architecture. Is it possible for me to create a print preview window myself ? How does MFC handle this ? Are there any special processing need to be done or keep in mind when showing the printer output on screen ? I've read that MFC used 2 DCs for print preview purposes. Do I need to do this as well if Im goin for a custom print preview ?

Your input is highly appreciated ! tia.

P.S. i use Visual Studio 6 and there is no option to change this to a newer version just as there is no way for me to add doc/view support.

+1  A: 

Check this link from CodeProject: Print Preview without Doc/View Architecture

Naveen
A: 

Print preview isn't that special. It just means that you have to render to screen (or bitmap) what you'd otherwise would render to the printer DC. This primarly means using the page size, and providing a UI control for the prev/next page.

MSalters
A: 

I had tweeked this code in order to compile it as static lib. It is for dialog based applications.
If you don't need special functionality it will work ok for you.

I had to dig through MFC mechanisms to add extra functionality but at the end I dropped it. If you know other programming languages, try to find a print preview control in that language, make it a dll and use it from your MFC application.

For example, I found the NicePreview control for Delphi and it worked, for me, beautifully !

Nick D
A: 

if you managed to print your output to a file in an RTF format and displayed it on screen would this solve the problem?

A.Rashad
A: 

To Nick D: I have the same preview in .Net applications by FastReport.Net: http://www.fast-report.com/en/products/FastReport.Net-screenshots.html

Merl