Print Preview without Document/View architecture 
Author Message
 Print Preview without Document/View architecture

I am working with the Microsoft Visual C++ 4.2 compiler. How can I
develope a Print Preview, without using the Document/View architecture,
but using the predefined preview-dialog in the mfc. Is it possible to use
a device context as a function parameter? Is it useful to create the base
class for a printing class library with a Cview class?



Mon, 30 Aug 1999 03:00:00 GMT  
 Print Preview without Document/View architecture

I am working with the Microsoft Visual C++ 4.2 compiler. How can I
develope a Print Preview, without using the Document/View architecture,
but using the predefined preview-dialog in the mfc. Is it possible to use
a device context as a function parameter? Is it useful to create the base
class for a printing class library with a Cview class?



Sun, 05 Sep 1999 03:00:00 GMT  
 Print Preview without Document/View architecture

I am working with the Microsoft Visual C++ 4.2 compiler. How can I
develope a Print Preview, without using the Document/View architecture,
but using the predefined preview-dialog in the mfc. Is it possible to use
a device context as a function parameter? Is it useful to create the base
class for a printing class library with a Cview class?



Sun, 05 Sep 1999 03:00:00 GMT  
 Print Preview without Document/View architecture

I am working with the Microsoft Visual C++ 4.2 compiler. How can I
develope a Print Preview, without using the Document/View architecture,
but using the predefined preview-dialog in the mfc. Is it possible to use
a device context as a function parameter? Is it useful to create the base
class for a printing class library with a Cview class?



Sun, 05 Sep 1999 03:00:00 GMT  
 Print Preview without Document/View architecture

Quote:

> I am working with the Microsoft Visual C++ 4.2 compiler. How can I
> develope a Print Preview, without using the Document/View architecture,
> but using the predefined preview-dialog in the mfc. Is it possible to use
> a device context as a function parameter? Is it useful to create the base
> class for a printing class library with a Cview class?

Here's how I did it.  It's tricky and a bit of a kludge but I don't know
of any other approach that works without building your own previewer.

First I created my own subclass of CDocument, CFrameWnd, and CView which
will be used to do the Print Previewing (CPrintDoc, CPrintFrame, and
CPrintView in the example below).  You also should have a dummy menu
resource so that the print preview mechanism thinks its doing its
thing.  The menu doesn't need to have anything in it, but it should be a
valid menu resource.  Then where you want to begin the Print Preview,
enter code that looks something like this:

pDocTemplate = new CSingleDocTemplate(
  IDR_PRINTFRAME,  // point to your dummy menu resource
  RUNTIME_CLASS(CPrintDoc),
  RUNTIME_CLASS(CPrintFrame),
  RUNTIME_CLASS(CPrintView));
AddDocTemplate(pDocTemplate);

pDocTemplate->OpenDocumentFile(NULL);

Then on the CPrintView object that is created, call it's print preview
method like this:

printView->PrintPreview();  // This activates the print preview window

The tricky part is getting a pointer to the print view that is created.
I do it by examining the document in pDocTemplate.

The call to OpenDocumentFile brings up the Print Preview window just
like the document view architecture does.  You might have to play with
the show command to get the window to display the first time.  You then
put your print preview drawing inside OnDraw of your CPrintView subclass
of CView.  I leave it to you to do this part.

For clean up, enter clean up code in OnEndPrintPreview of your
CPrintView subclass.  The clean up must include closing and destroying
the frame window, CPrintFrame, plus deleting the document template you
created above.  This clean up is also a bit tricky because you're inside
the view that itself is being destroyed when you destroy CPrintFrame.
You can handle this by notifying yourself to do it later.  I also had to
destroy a document manager object that was created when AddDocTemplate
was called.  If your application already has a document manager object
(check AfxGetApp()->m_pDocManager) don't destroy it.

This should get you started.  It's not pretty, but it works for me.



Sun, 05 Sep 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Print Preview without Document/View architecture

2. How to Embed Microsoft Word Document without using document view architecture

3. Use of CView without document-view architecture

4. Windows Explorer style without Document/View architecture support.

5. CView without document view architecture

6. Use CFormView without document / view architecture ?

7. Printing without View/Doc Architecture

8. How to make a class for printing and preview without using the document/view architecture?

9. Print Preview WITHOUT Doc/View

10. Print Preview without Doc/View

11. CFormView as default view w/o document-view architecture

12. print in landscape without document/view

 

 
Powered by phpBB® Forum Software