The information below is about a deprecated usage of FoxyPreviewer, that is not recommnded any more. The usage shown below is still valid, but is considered risky, for the reasons presented in the following link:


Deprecated.png
  • THE ORIGINAL MODE (Complete mode) NOT RECOMMENDED


With just four lines of code you'll be able to use FoxyPreviewer at full power:

LOCAL loReport AS "PreviewHelper" OF "FoxyPreviewer.App" 
loReport = CREATEOBJECT("PreviewHelper") 
loReport.AddReport(_Samples + "\Solution\Reports\colors.frx", "FOR Client = 'VFPx' ") &&' FRX File, Clauses 
loReport.RunReport() 

The main file is FOXYPREVIEWER.APP that contains the PreviewHelper class that is the class that you need to instantiate to have the new toolbar options. It uses the ReportListener's ExtensionHandler class to make all the changes in the original toolbar.

COMPARISON BETWEEN THE COMPLETE MODE AND THE SIMPLIFIED (AND RECOMMENDED) MODES

Feature Default VFP 9 Preview FoxyPreviewer Simplified FoxyPreviewer Complete
Search in Preview x Yes Yes
Printer prompt dialog button x Yes Yes
Preview miniatures of pages x Yes Yes
Save as Image file x Yes Yes
Save as PDF x Yes Yes
Save as RTF x Yes Yes
Save as XLS / XML x Yes Yes
Save as HTML x Yes Yes
Save as MHTML x Yes x
Save as TXT x x Yes
Copies spinner x Yes Yes
Printers combo x Yes Yes
Justified texts x Yes Yes
Big buttons x Yes Yes
Send emails x Yes Yes
Change settings interactively x Yes Yes
Localized language x Yes Yes
Enhanced Progress bar x Yes Yes
Lines of code needed to run a report 1 1 4
Adress book to send emails x Yes Yes
Change buttons images automatically x Yes Yes
Expand numeric fields to fit x Yes Yes
Add watermarks to reports x Yes x
Tagged formatting x Yes x
Dot-Matrix printer friendly Yes (with ReportBehavior 80) x Yes (with .lUseListener = .F.)
Print twice in page x Yes x



DISTRIBUTION FOR THE COMPLETE MODE

FoxyPreviewer consists of a set of separate utilities, that were adapted to work together.
These files include classes, prgs, images, dlls and header files.

In order to simplify the distribution and to avoid adding many individual files to your project, all the related files have been compiled into a single APP file - FoxyPreviewer.App

The usage for the Complete mode is simple:

Store the file FoxyPreviewer.App in the same folder that you have your EXE or the Report*.App files.
Add to your main project just one file: FOXYPREVIEWERCALLER.PRG

The usage is EXACTLY the same as if you were using the PRG - the only difference is that instead of starting the FoxyPreviewer class directly, you'll access the Helper class that I created that you'll include in your EXE.
This was necessary in order to allow FoxyPreviewer to access the FRX files from your EXE. Being an external library, FoxyPreviewer.App can't access directly the FRX that are in your EXE. That's the reason that I'm asking you to include the helper file, FoxyPreviewerCaller.Prg in your EXE. That way, the helper class is inside your EXE, and it can access your FRX, and pass them to the Previewer class.

Behind the scenes, this helper class stores a copy of the FRX classes from your EXE in a TEMP file, that is used by FoxyPreviewer. This helper class does the needed cleanups, deleting the temporary files. All the properties available in the main class are available in the helper as well, so you'll use it the same way:

SET PROCEDURE TO FoxyPreviewerCaller.prg ADDITIVE 

LOCAL loReport as "FoxyPreviewerCaller" OF "FoxyPreviewerCaller.Prg"
loReport = CREATEOBJECT("FoxyPreviewerCaller")

WITH loReport as ReportHelper
	.AddReport("Sample.frx", "RANGE 1,1 NODIALOG") && ' The RANGE clause is optional !
	.RunReport()
	
	DO CASE
	CASE .lPrinted	
		MESSAGEBOX("Report was printed !",64, "Report status")
	CASE .lSaved
		MESSAGEBOX("Report was saved as file:" + CHR(13) + .cDestFile,;
			64, ;
			"Report status")
	OTHERWISE
		MESSAGEBOX("Report Preview was closed without saving or printing",48, "Report status")
	ENDCASE
ENDWITH


If you don't want to use a separate APP file, you can have FoxyPreviewer included in your project normally.

Make sure to include all classes, VCX/VCT, images, the header files (*.H), the dialog forms, the file FoxyPreviewer.Prg in your Project, except the file LIBHPDF.DLL and compile. That's all. All these files are in the "Source" folder of FoxyPreviewer. There will be just one single file to take an extra care: LIBHPDF.DLL, that you need to distribute separately, in order to allow the PDF generation. Your EXE will not be able to use the functions of the DLL if it is not stored at any disk location.

Then, instead of calling FoxyPreviewer.App, you'll call Foxypreviewer.PRG

BUT:
THIS IS NOT RECOMMENDED !
That's because FoxyPreviewer is in constant development, and changes, fixes, enhancements may be applied very soon. When that happens, you'll need to update all the sources in your project. So, the recommended is to use just the APP, and distribute it separately. That way, you wont need to update your EXE when a new Version of FoxyPreviewer is released.

AUTOMATING WITH INTELLISENSE IN THE COMPLETE MODE

There is a small PRG that updates the FOXCODE table in order to add an Intellisense script to use it. Please run the file INSTALLFOXCODE.PRG to update the Intellisense.

To test it, open any empty PRG or Method, and just type:

FOXYPREVIEW and a complete script with all available options will be shown. Obviously, you may delete or comment all the properties that you don't want to use.

Last edited Nov 19, 2012 at 10:45 AM by VfpImaging, version 8