?
Solved

How to subclass CPrintPreview ?

Posted on 1998-04-18
2
Medium Priority
?
530 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 400 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

770 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