JavaScript Editor js editor     Web development 

Main Page

To facilitate the SET REPORTBEHAVIOR 90 setting, Visual FoxPro ships with a default preview container factory application, ReportPreview.App. It is located in the HOME() directory along with the other tools, and is referenced by default in the _REPORTPREVIEW system variable.

This topic describes the capabilities of the Preview Container component delivered by ReportPreview.App, additional to the standard Preview Container API.


Object Diagram

The following illustration shows the object diagram of the default preview container as it exists after the report engine has called the Show() method. Prior to that point, the oForm and oForm.Toolbar member objects may not have been instantiated:

Visual FoxPro Preview Object Diagram graphic

A proxy object is used because in order to support numerous clauses of the REPORT FORM… PREVIEW command in object-assisted mode, the preview may instantiate one of a number of specific form classes derived from the parent class frxPreviewForm as its oForm reference:

Class Name Derived From Notes



Visual FoxPro base form class



Implements error handling and large font support.



Implements the Preview Container API.

.ShowWindow = 1 - in top-level form



.ShowWindow = 2 - As top-level form



.ShowWindow = 0 - In Screen



.Desktop = .T.

The properties and methods described below are members of the frxPreviewProxy object.

Additional Properties and Methods

In addition to the standard preview container API, the default component returned by ReportPreview.App exposes other properties and methods that can be used to control the appearance of the Preview window when object-assisted reporting mode is used.


These properties control the initial state of the preview window only. If set to non-default values, these properties take precedence over any preferences restored from the resource file.

Property Name Type Description



Specifies the vertical offset from the top of the main Visual FoxPro window of the of the preview form, in pixels.



Specifies the left horizontal offset from the left side of the main Visual FoxPro window of the of the preview form, in pixels.



Specifies the horizontal size of the preview form in pixels.



Specifies the vertical size of the of the preview form, in pixels.



Specifies that the preview window toolbar should be initially visible.



Specifies the caption of the preview window.



Specifies the initial number of pages rendered on the preview form. Valid values are 1, 2, or 4.



Specifies the initial zoom level of the preview window. Possible values are:

1 - 10%

2 - 25%

3 -50%

4 - 75%

5 - 100% (default)

6 - 150%

7 - 200%

8 - 300%

9 - 500%

10 - whole page



Specifies the initial page to render on the preview form. The default is 1. If it is greater than the number of pages available the last page will be displayed.



Specfies whether the preview form should be a standalone top form. This will force a modeless (NOWAIT) preview session, and the toolbar is automatically docked at the top of the form. Default value is false (.F.).



Specifies that the toolbar buttons should show text captions. Default value is false (.F.).


In addition to the methods specified by The Preview Container API , the default preview container also exposes all public methods of the base Form class.

The following additional methods can be called after the preview container is visible:

Method Description

SetCurrentPage( iPageNo )

Moves to a specific page number.

SetCanvasCount( iCount )

Adjusts the number of pages rendered on the preview form.

SetZoomLevel( iLevel )

Adjusts the scale of the rendered pages.

SetExtensionHandler( oRef )

Assigns an extension handler (See below)

The Extension Handler Interface

The default preview container has a specific mechanism that allows you to modify or extend the functionality of the preview user interface without subclassing or recompiling the source code.

You use SetExtensionHandler() to pass the default preview container a reference to an object that implements a specific set of "hook" methods that are invoked at specific points. See below for the API and sample usage.

Preview Extension Handler Properties

Property Description


This is a back-reference to the preview form. If this property does not exist, it will be created by the default preview container via an ADDPROPERTY() call, and assigned a reference to the preview form. The preview container nulls out the back reference automatically before releasing to avoid an object reference loop that might prevent it from doing so.

Useful properties of .PreviewForm:

  • .PreviewForm.oReport references the active report listener

  • .PreviewForm.Toolbar references the preview form's toolbar object.

Preview Extension Handler Methods

These methods must be implemented by a candidate Extension Handler.

Method Description

AddBarsToMenu( cPopupName, iNextBarNum )

This method is called from the preview form's RightClick() event, directly prior to the ACTIVATE POPUP (m.cPopupName) statement, so you can potentially remove menu bars or redefine them.

cPopupName is the name of the popup.

iNextBarNum is the next available bar number.

Because you cannot use the THIS keyword in a popup ON SELECTION.. command, the preview form makes a reference to itself available in a variable oRef.

HandledKeyPress( nKey, nModifier )

This method is called from the preview form's Keypress() event. Return true (.T.) if you wish to replace the default response to a specific key press. This method is called before the preview form's native keypress handling, so you may override selected keypress events.

Show( iStyle )

This method is called from the preview form's Show() method. You will be able to manipulate the preview toolbar through the THIS.PreviewForm.Toolbar reference. The toolbar actually gets created in the preview form's Init() event but as the extension handled has not been assigned at that point, the Show() is the best place for configuration and decoration code.

Note that the toolbar itself also has a PreviewForm back-reference to the preview form, so you could add command buttons with Click() code like THIS.Parent.PreviewForm.ExtensionHandler.MyCustomMethod().


Called from the preview form's Paint() event, after the preview has finished rendering the pages.


Called from the preview form's Release() event. Returning false (.F.) from this method will prevent the preview form from closing.

Example: Customizing the preview container using an Extension Handler

The following example customizes the appearance of the preview window and also implements an extension handler that removes the ability to change the number of pages rendered simultaneously on the preview form.

В Copy Code
* Obtain an instance of the default preview container:
pc = .NULL.

* Set some initial properties:
    .Caption = "My Custom Preview Window"
    .ZoomLevel = 4   && 75%
    .CanvasCount = 1

* Create an instance of an Extension Handler:
xh = NEWOBJECT("MyRetroPreview")

* Assign it to the preview container:
pc.SetExtensionHandler( m.xh )

* Set up a report listener and give it our preview:
rl = NEWOBJECT("Reportlistener")
rl.ListenerType = 1
rl.PreviewContainer = pc

* Run a report:
REPORT FORM (_SAMPLES+"\solution\reports\colors.frx") OBJECT rl 

* Extension Handler Class:
DEFINE CLASS MyRetroPreview AS Custom

    PROCEDURE AddBarsToMenu( cPopup, iNextBar )
        * Remove the option to change page count:
        RELEASE BAR 8 OF (m.cPopup)

    PROCEDURE Show( iStyle )
        * Remove the option to change page count:
        THIS.PreviewForm.Toolbar.opgPageCount.Visible = .F.
        THIS.PreviewForm.CanvasCount = 1

    PROCEDURE HandledKeyPress( nKeyCode, nShiftAltCtrl )
        RETURN .F.

    PROCEDURE Paint()

    PROCEDURE Release()
        RETURN .T.


Use of the Resource File

The default preview container uses the current resource file (as returned by SET("RESOURCE",1) ) to remember the size, position, number of pages visible, zoom level, etc., for each report file.

The window and toolbar preferences are stored in the FOXUSER table with an ID of "9REPPREVIEW". Window and Toolbar position and size preferences are saved independently for each individual report file. The position and state of the preview toolbar is common to all report previews. If the resource file is not available, or read-only, then the window preferences are not saved.

See Also

JavaScript Editor js editor     Web development