Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Print preview question CExtPPVW Collapse All
Subject Author Date
Johnny Booth Oct 16, 2007 - 2:52 PM

I have a CView class which is using the CExtPPVW template. How can I tell when the user clicks on the Close button to end the print preview session?

There is a CView virtual method OnEndPrintPreview, but for some reason it does not get called in my derived class.

Technical Support Oct 17, 2007 - 1:14 PM

First, please make sure your class is declared as follows

class CYourView : public CExtPPVW < CView >
The CExtPPVW < CView > template based class in this case is derived from both CView class and CExtPPVW_Printable. The latter one provides a set of virtual methods for handling printing events like in MFC views. But signatures of OnEndPrintPreview() methods in these two classes are different
void CView::OnEndPrintPreview(
      CDC * pDC,
      CPrintInfo * pInfo,
      POINT,
      CPreviewView * pView
      )

void CExtPPVW_Printable::OnEndPrintPreview(
      CDC * pDC,
      CPrintInfo * pInfo,
      POINT point,
      CExtPPVW_HostWnd * pWndPrintPreviewHost
      )
Unfortunately we cannot use the CView::OnEndPrintPreview() signature because CExtPPVW provides the printing and print preview feature not only for MFC views. So make sure you are using the signature of CExtPPVW_Printable::OnEndPrintPreview().

Then find the CDrawView class in the DRAWCLI sample. It represents an MFC view window based on printing and print preview subsystem provided by Prof-UIS. If you add the following method into declaration of this class, then you will see a message box each time you exits the print preview mode.
      void OnEndPrintPreview(
            CDC * pDC,
            CPrintInfo * pInfo,
            POINT point,
            CExtPPVW_HostWnd * pWndPrintPreviewHost
            )
      {
            CExtPPVW_Printable::OnEndPrintPreview(
                  pDC,
                  pInfo,
                  point,
                  pWndPrintPreviewHost
                  );
            ::AfxMessageBox( _T("Print preview mode is off.") );
      }