|
#include "stdafx.h"
#include "EnhancedPreview.h"
#include "MultiPagePreview.h"
#include "resource.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CEnhancedPrintPreview plugIn(false);
IMPLEMENT_DYNCREATE(CEnhancedPrintPreview, CPlugInMap)
CEnhancedPrintPreview::CEnhancedPrintPreview()
{
}
CEnhancedPrintPreview::CEnhancedPrintPreview(bool special)
{
UNREFERENCED_PARAMETER(special);
AddObject();
}
CEnhancedPrintPreview::~CEnhancedPrintPreview()
{
TRACE("CEnhancedPrintPreview::~CEnhancedPrintPreview()\n");
}
BEGIN_MESSAGE_MAP(CEnhancedPrintPreview, CPlugInMap)
//{{AFX_MSG_MAP(CEnhancedPrintPreview)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEnhancedPrintPreview message handlers
bool CEnhancedPrintPreview::IsPlugInFor(CRuntimeClass *pClass)
{
if (pClass->IsDerivedFrom(RUNTIME_CLASS(CView)))
{
// we are only a plug-in for any view class
// as the view classes support the preview option
return true;
}
return false;
}
CPlugInMap* CEnhancedPrintPreview::CreateMapObject()
{
return new CEnhancedPrintPreview;
}
void CEnhancedPrintPreview::OnFilePrintPreview()
{
if (IsPreCall())
{
// were replacing the standard MFC print preview and replacing it with
// our enhanced version.
SuppressThisMessage();
// replace the default print preview with ours!
// 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;
// DoPrintPreview's return value does not necessarily indicate that
// Print preview succeeded or failed, but rather what actions are necessary
// at this point. If DoPrintPreview returns TRUE, it means that
// OnEndPrintPreview will be (or has already been) called and the
// pState structure will be/has been deleted.
// If DoPrintPreview returns FALSE, it means that OnEndPrintPreview
// WILL NOT be called and that cleanup, including deleting pState
// must be done here.
CView *pView = static_cast<CView*>(m_pPlugInFor);
if (!pView->DoPrintPreview(IDD_PREVIEW, pView, RUNTIME_CLASS(CMultiPagePreviewView), pState))
{
// In derived classes, reverse special window handling here for
// Preview failure case
TRACE0("Error: DoPrintPreview failed.\n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
delete pState; // preview failed to initialize, delete State now
pState = NULL;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
A research and development programmer working for a pharmaceutical instrument company for the past 17 years.
I am one of those lucky people who enjoys his work and spends more time than he should either doing work or reseaching new stuff. I can also be found on playing DDO on the Cannith server (Send a tell to "Maetrim" who is my current main)
I am also a keep fit fanatic, doing cross country running and am seriously into [url]http://www.ryushinkan.co.uk/[/url] Karate at this time of my life, training from 4-6 times a week and recently achieved my 1st Dan after 6 years.