User Tools

Site Tools


printpreviewclass_overview.htm
Navigation:  ABC Library Reference > PrintPreviewClass >====== PrintPreviewClass Overview C6H0009.jpg ====== Previous pageReturn to chapter overviewNext page

The PrintPreviewClass is a WindowManager that implements a full-featured print preview dialog.

PrintPreviewClass Concepts

This print preview facility includes pinpoint zoom-in and zoom-out with configurable zoom magnification, random and sequential page navigation, plus thumbnail views of each report page. You can even specify how many rows and columns of thumbnails the print preview facility displays.

When you finish viewing the report, you can send it directly to the printer for immediate What You See Is What You Get (WYSIWYG) printing.

The PrintPreviewClass previews reports in the form of a Windows metafile (.WMF) per report page. The PREVIEW attribute generates reports in Windows metafile format, and the Clarion Report templates provide this capability as well. See PREVIEW in the Language Reference for more information, and see Procedure Templates--Report for more information on Report templates.

PrintPreviewClass Relationship to Other Application Builder Classes

The PrintPreviewClass is derived from the WindowManager class (see Window Manager Class for more information).

The PrintPreviewClass relies on the PopupClass and, optionally, the TranslatorClass to accomplish some of its tasks. Therefore, if your program instantiates the PrintPreviewClass, it should also instantiate the PopupClass and may need the Translator class as well. Much of this is automatic when you INCLUDE the PrintPreviewClass header (ABREPORT.INC) in your program's data section. See the Conceptual Example.

The ASCIIPrintClass and the ReportManager use the PrintPreviewClass to provide a print preview facility.

PrintPreviewClass ABC Template Implementation

The Report and Viewer Procedure templates and the Report Wizard Utility template automatically generate all the code and include all the classes necessary to provide the print preview facility for your application's reports.

These Report templates instantiate a PrintPreviewClass object called Previewer for each report procedure in the application. This object supports all the functionality specified in the Preview Options section of the Report template's Report Properties dialog. See Procedure Templates–Report for more information.

The template generated ReportManager object (ThisWindow) “drives” the Previewer object, so generally, the only references to the Previewer object within the template generated code are to initially configure the Previewer's properties.

PrintPreviewClass Source Files

The PrintPreviewClass source code is installed by default to the Clarion \LIBSRC folder. The PrintPreviewClass source code and its respective components are contained in:

ABREPORT.INC PrintPreviewClass declarations
ABREPORT.CLW PrintPreviewClass method definitions
ABREPORT.TRN PrintPreviewClass user interface text

Zoom Configuration

The user interface text and the standard zoom choices the PrintPreviewClass displays at runtime are defined in the ABREPORT.TRN file. To modify or customize this text or the standard zoom choices, simply back up the ABREPORT.TRN file then edit it to suit your needs. See ZoomIndex for more information.

PrintPreviewClass Conceptual Example

The following example shows a typical sequence of statements to declare, instantiate, initialize, use, and terminate a PrintPreviewClass object and some related objects.

This example uses the PrintPreviewClass object to preview a very simple report before printing it. The program specifies an initial position and size for the print preview window and allows custom zoom factors.

  PROGRAM

  INCLUDE('ABREPORT.INC')           !declare ReportManager &

                                    !PrintPreviewClass

  MAP

  END

GlobalErrors ErrorClass

VCRRequest  LONG(0),THREAD

Customer   FILE,DRIVER('TOPSPEED'),PRE(CUS),THREAD

BYNUMBER   KEY(CUS:CUSTNO),NOCASE,OPT,PRIMARY

Record      RECORD,PRE()

CUSTNO       LONG

Name         STRING(30)

State        STRING(2)

           END

          END

Access:Customer CLASS(FileManager)      !declare Access:Customer object

Init             PROCEDURE

               END

Relate:Customer CLASS(RelationManager)  !declare Relate:Customer object

Init             PROCEDURE

               END

CusView  VIEW(Customer)                 !declare CusView VIEW

        END

PctDone  BYTE                           !track progress variable

report  REPORT,AT(1000,1542,6000,7458),PRE(RPT),FONT('Arial',10,,),THOUS

     HEADER,AT(1000,1000,6000,542),FONT(,,,FONT:bold)

      STRING('Customers'),AT(2000,20),FONT(,14,,)

      STRING('Id'),AT(52,313),TRN

      STRING('Name'),AT(2052,313),TRN

      STRING('State'),AT(4052,313),TRN

     END

detail  DETAIL,AT(,,6000,281),USE(?detail)

      STRING(@n-14),AT(52,52),USE(CUS:CUSTNO)

      STRING(@s30),AT(2052,52),USE(CUS:NAME)

      STRING(@s2),AT(4052,52),USE(CUS:State)

       END

     FOOTER,AT(1000,9000,6000,219)

      STRING(@pPage <;<;<;#p),AT(5250,31),PAGENO,USE(?PageCount)

     END

    END

ProgressWindow WINDOW('Progress…'),AT(,,142,59),CENTER,TIMER(1),GRAY,DOUBLE

        PROGRESS,USE(PctDone),AT(15,15,111,12),RANGE(0,100)

        STRING(),AT(0,3,141,10),USE(?UserString),CENTER         STRING(),AT(0,30,141,10),USE(?TxtDone),CENTER

        BUTTON('Cancel'),AT(45,42),USE(?Cancel)

       END

ThisProcedure CLASS(ReportManager)        !declare ThisProcedure object

Init           PROCEDURE(),BYTE,PROC,VIRTUAL

Kill           PROCEDURE(),BYTE,PROC,VIRTUAL

             END

CusReport   CLASS(ProcessClass)           !declare CusReport object

TakeRecord   PROCEDURE(),BYTE,PROC,VIRTUAL

           END

Previewer   PrintPreviewClass             !declare Previewer object

                                         ! for use with ThisProcedure

 CODE

 ThisProcedure.Run()                     !run the procedure

ThisProcedure.Init  PROCEDURE()           !initialize ThisProcedure

ReturnValue  BYTE,AUTO

 CODE

 GlobalErrors.Init

 Relate:Customer.Init

 ReturnValue = PARENT.Init()

 SELF.FirstField = ?PctDone

 SELF.VCRRequest &amp;= VCRRequest

 SELF.Errors &amp;= GlobalErrors

 Relate:Customer.Open

 OPEN(ProgressWindow)

 SELF.Opened=True

 CusReport.Init(CusView,Relate:Customer,?TxtDone,PctDone,RECORDS(Customer))

 CusReport.AddSortOrder(CUS:BYNUMBER)

 SELF.AddItem(?Cancel,RequestCancelled)

 SELF.Init(CusReport,report,Previewer)  !register Previewer with ThisProcedure

 SELF.Zoom = PageWidth

 Previewer.AllowUserZoom=True           !allow custom zoom factors

 Previewer.Maximize=True                !initially maximize preview window

 SELF.SetAlerts()

 RETURN ReturnValue

ThisProcedure.Kill  PROCEDURE()

ReturnValue      BYTE,AUTO

 CODE

 ReturnValue = PARENT.Kill()

 Relate:Customer.Close

 Relate:Customer.Kill

 GlobalErrors.Kill

 RETURN ReturnValue

CusReport.TakeRecord PROCEDURE()

ReturnValue      BYTE,AUTO

SkipDetails BYTE

 CODE

 ReturnValue = PARENT.TakeRecord()

 PRINT(RPT:detail)

 RETURN ReturnValue

Access:Customer.Init PROCEDURE

 CODE

 PARENT.Init(Customer,GlobalErrors)

 SELF.FileNameValue = 'Customer'

 SELF.Buffer &amp;= CUS:Record

 SELF.Create = 0

 SELF.LazyOpen = False

 SELF.AddKey(CUS:BYNUMBER,'CUS:BYNUMBER',0)

Relate:Customer.Init PROCEDURE

 CODE

 Access:Customer.Init

 PARENT.Init(Access:Customer,1)

printpreviewclass_overview.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1