Article ID: 189580
Article Last Modified on 11/21/2006
//MyPreviewView.h
#include <afxpriv.h>
class CMyPreviewView : public CPreviewView
{
private:
DECLARE_DYNCREATE(CMyPreviewView)
protected:
virtual void PositionPage(UINT nPage);
};
=======================================================
//MyPreviewView.cpp
#include "stdafx.h"
#include "MyPreviewView.h"
IMPLEMENT_DYNCREATE(CMyPreviewView, CPreviewView )
///////////////////////////////////////////////////////////////////
void CMyPreviewView::PositionPage(UINT nPage)
{
CPreviewView::PositionPage(nPage);
if(m_nZoomState == ZOOM_OUT)
EnableScrollBarCtrl(SB_VERT, TRUE);
}
================================================================
Add OnFilePrintPreview() to your application's view class, and put your
CPreviewView-derived class name in the call to DoPrintPreview:
void CScribbleView::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;
// 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.
if (!DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, this,
RUNTIME_CLASS(CMyPreviewView), 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.
}
}
==============================================================
Change your view's message map so that it has OnFilePrintPreview() in it:
ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview)Add the appropriate #include to your applications's view class, such as:
#include "MyPreviewView.h"Add the following line to your view class's header file:
void OnFilePrintPreview();
Additional query words: scrollbar
Keywords: kbbug kbfix kbgdi kbprint kbvc600fix KB189580