Solved

How to subclass CPrintPreview ?

Posted on 1998-04-18
2
504 Views
Last Modified: 2013-11-20
I have created a mdi-application. I want to create a mdi-child-window with an outlook same like the print preview view without any view associated with it. In this print preview window I want to do something like a report output for my program. The report I want to show in the preview view shall not be displayed in another mdi-view, it shall only appear in my print preview window.

How is it possible ?
0
Comment
Question by:atari
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
RONSLOW earned 100 total points
ID: 1300366
In answer to your question "How to subclass CPrintPreview ?"

Derive your class CMyPreviewView from CPreviewView

Override OnFilePrintPreview for you view class (say CMyView)

Make a copy of the original and change it as follows
void CMyView::OnFilePrintPreview()
{
    // In derived classes, implement special window handling here
    // Be sure to Unhook Frame Window close if hooked.

    // must not create this on the frame. Must outlive this function
    CPrintPreviewState* pState = new CPrintPreviewState;

    if (!DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, this,
                RUNTIME_CLASS(CMyPreviewView), pState))
//                            ^^^^^^^^^^^^^^
// Change this to be your derived CMyPreviewView class
//
    {
        // In derived classes, reverse special window handling
        // here for Preview failure case

        TRACE0("Error: DoPrintPreview failed");
        AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
        delete pState;      // preview failed to initialize,
                    // delete State now
    }
}

See also TN030: Customizing Printing and Print Preview


0
 
LVL 1

Author Comment

by:atari
ID: 1300367
Yes, that's what I was searching for. At the weekend I found in MFC/SRC the file Viewprev.cpp which described what happens while print preview. And therefrom I found out that I must subclass CPreviewView and not CPrintPreview. It's again the help file of developer studio, in which you find nothing. Then somewhere I also found out that Technical Note 030 describe what to do if I want to subclass CPreviewView. Today in the morning I want to delete this question, but you have answered before, so I think, you have really earned the points.
Thank you
bye,
atari
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
either24  challenge 19 105
withoutTen challenge 14 137
Modbus - whats the maximum I can store in one register? 4 82
Increment column based of a FK 8 50
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question