Solved

How to subclass CPrintPreview ?

Posted on 1998-04-18
2
497 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 94
Define unique primary key 9 95
ASP.NET C# MessageBox.Show Showing a modal dialog box or form when the application ... 2 160
wordcount challenge 11 130
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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