Solved

How to subclass CPrintPreview ?

Posted on 1998-04-18
2
466 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
2 Comments
 
LVL 10

Accepted Solution

by:
RONSLOW earned 100 total points
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
function returning CString in a regular win32 DLL 8 144
deburging in oracle form 12 76
NotAlone Challenge 20 70
wordmultiple challenge 12 87
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now