Wiki Home

Maximize Print Preview

(Updated: 2009.09.29 06:07:07 PM)
Namespace: VFP
For new object assisted reports you may use this code provided by BorislavBorissov in UT message #1272692
LOCAL oForm, wnd_name
LOCAL loRef as ReportListener
IF SET("ReportBehavior") == 80
   oForm             = CREATEOBJECT("Form")
   oForm.Caption     = [some caption]
   oForm.Name        = "PrintPreview"
   oForm.WindowState = 2   && Maximised
   oForm.Visible     = .t.
   wnd_name          = oForm.Name
   REPORT FORM (report name here) NOCONSOLE TO PRINTER PROMPT PREVIEW WINDOW (wnd_name)
ELSE
   EXTERNAL CLASS frxPreview.vcx
   oForm = NEWOBJECT([frxpreviewForm],[frxPreview],_REPORTPREVIEW)
   loRef = NULL
   DO (_REPORTOUTPUT) WITH 1, loRef
   oForm.WindowState      = 2
   loRef.PreviewContainer = oForm
   REPORT FORM (report name here) NOCONSOLE TO PRINTER PROMPT PREVIEW OBJECT loRef
ENDIF

If you want a report to always preview maximized, put the following single line in the Init or Before Open Tables Event of the Data Environment of that report:
ZOOM WINDOW "Report Designer" MAX

There is no need to actually have any tables automatically opened or such in the Data Environment.

I use those same events to on occasion setup an EXTERNAL keyword command line to an array that may exist within a report so an error isn't thrown when the project with that report is compiled.

Carl Warner


How to Maximize the Print Preview window programatically:
KEYBOARD "{Ctrl+F10}"
REPORT FORM myGreatReport PREVIEW

You can bypass macro assignments with PLAIN and clear the buffer before you send the Ctrl+F10 with CLEAR. Craig Roberts
KEYBOARD "{Ctrl+F10}" PLAIN CLEAR
REPORT FORM myGreatReport PREVIEW

=repwindow(.t.)
REPORT FORM myReport PREVIEW WINDOW repwindow TO PRINTER PROMPT
=repwindow(.f.)


FUNCTION repwindow
PARAMETERS tDefine
LOCAL nWidth, nHeight
IF tDefine
   nWidth = _SCREEN.WIDTH/FONTMETRIC(6,_SCREEN.FONTNAME,_SCREEN.FONTSIZE)
   nHeight = _SCREEN.HEIGHT/FONTMETRIC(1,_SCREEN.FONTNAME,_SCREEN.FONTSIZE)-2
   DEFINE WINDOW repwindow AT 0,0 SIZE nHeight,nWidth SYSTEM ZOOM ;
      CLOSE FLOAT TITLE "Report Preview" ;
      FONT _SCREEN.FONTNAME,_SCREEN.FONTSIZE NAME repwindow
ELSE
   RELEASE WINDOW repwindow
ENDIF

[ Source: Randy Jean on Pro Fox list 20.Apr.2001 Msg.#33452 ]
oForm = CREATEOBJECT("Form")

WITH oForm
   .Caption = "Preview Title"
   .WindowState = 2    && Maximized
   .Show()
   REPORT FORM yourreport PREVIEW WINDOW (.Name)
   .Release()
ENDWITH

Fred Taylor

News: microsoft.public.fox.vfp.reports.printing
Subject: Re: Report preview window size control
Date: 05/19/2002
Category VFP Reports Category Tips And Tricks Category Code Samples