TPreview

Fonte: source/classes/rpreview.prg

Standalone class (not inherited from TControl)

TPreview is the print preview window engine for FiveWin. It is automatically invoked when using the PREVIEW clause with the PRINTER command, and provides a full-featured preview environment with zoom, page navigation, two-page view, printing, and export capabilities. It is also used internally by TReport for report preview.

Key DATA Members

DATATypeDescription
oDeviceTPrinterThe printer device object being previewed
oReportTReportOptional TReport object bound to this preview
oWndTWindowThe preview window
oBarTReBarToolbar with navigation and action buttons
nPageNumericCurrent page number (1-based)
nZFactorNumericZoom factor multiplier
lTwoPagesLogicalTwo-page side-by-side view mode
lZoomLogicalZoom mode active when resizing window
aFactorArrayArray of available zoom factor values
oMeta1TMetafileCurrent page metafile for rendering
oMeta2TMetafileSecond page metafile (two-page mode)
oLvwTListViewPage thumbnail list view (mini pages)

Class DATA

CLASSDATADescription
bPrintCode block executed on Print action
bExportToWordCode block for Word export
bEmailCode block for Send Email action
bSaveAsPDFDefault: saves as PDF
bSaveAsWordDefault: saves as DOC

Methods

MethodDescription
New( oDevice, oReport )Create preview for a printer device and optional report
Activate()Show the preview window maximized
BuildWindow()Construct the preview window and toolbar
BuildButtonBar()Build the rebar toolbar with navigation buttons
BuildMenu()Build the zoom and two-page popup menus
GoPage( nPage )Go to a specific page number
NextPage()Move to the next page
PrevPage()Move to the previous page
TopPage()Move to the first page
BottomPage()Move to the last page
Zoom( lMenu )Toggle zoom mode or select zoom level from menu
TwoPages( lMenu )Toggle two-page view or select from menu
PrintPage()Print the current page
SetFactor( nValue )Set zoom factor directly
SaveAs( lPDF, cFile, lView )Save as PDF (.T.) or DOC (.F.)
SaveAsMenu()Show Save As type selection dialog
ExportToMSWord()Export current document to Microsoft Word
ExportToMSExcel()Export current report data to Excel (requires report with bInit/bToExcel)
SendEmail()Send the document as an email attachment
SelPrinter( cPrinter )Change output printer from within preview
PaintMeta()Repaint the current page metafile
VScroll( nType, lPage, nSteps )Vertical scrolling
HScroll( nType, lPage, nSteps )Horizontal scrolling
CheckStyle()Apply dark mode styling when Windows dark theme is active

Example: Print Preview with PRINTER Command

#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd TITLE "Print Preview Demo" SIZE 600, 400

   @ 20, 20 BUTTON "&Print Preview" SIZE 120, 30 OF oWnd ;
      ACTION DoPreview()

   ACTIVATE WINDOW oWnd CENTERED

return nil

function DoPreview()

   PRINTER oPrn PREVIEW
      PAGE
         @ 10, 10 SAY "Hello from FiveWin!" FONT oPrn:oFont
         @ 30, 10 SAY "Page: " + Str( oPrn:nPageCount )
      ENDPAGE
      PAGE
         @ 10, 10 SAY "This is page 2"
      ENDPAGE
   ENDPRINTER

return nil

Notes

Veja Também