| BUG: Print Preview Scroll Bar Disappears after Zoom In, Zoom OutID: Q189580 
 | 
In MFC's Print Preview, there is a toolbar that contains zoom-in and zoom- out buttons, and there may be a vertical scroll bar. The scroll bar allows the user to scroll within a page when zoomed in, or it can be used to move between pages when zoomed out. When completely zoomed out, the arrow buttons on the scroll bar allow the user to move from one page to another. If the user presses the zoom-in button, and then zooms out completely, the scroll bar disappears and does not reappear until the user exits Print Preview and starts it up again from the menu.
The scroll bars are not being re-enabled after zooming out.
There is no easy workaround, but an approximate workaround below allows the
user to scroll through pages using the up/down arrows of the scroll bars,
but the "thumbs" will not appear proportionally.
Derive a class from CPreviewView (you need to include Afxpriv.h) and
override PositionPage(). You can use code similar to the following:
   //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);
   }
   ================================================================ 
   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.
      }
   }
   ============================================================== 
   ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) 
   #include "MyPreviewView.h" 
   void OnFilePrintPreview(); Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
For more information on Print Preview, see the MFC Technote in the Visual
C++ documentation:
   TN030: "Customizing Printing and Print Preview"
Additional query words: scrollbar kbprinting kbmfc400bug kbmfc410bug kbmfc420bug kbmfc500bug
Keywords          : 
Version           : WINNT:4.0,4.1,4.2,5.0
Platform          : winnt 
Issue type        : kbbug Last Reviewed: August 2, 1999