Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to subclass CPrintPreview ?

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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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 video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

604 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