6

The LA Fox Developer Newsletter
VFUG’s Hot Tips (Con't from page 5)

foxpro desktop). NO T E This exampie previews tne 5Odbcpro and 5Odbc reports found in the filespec directory * of VFP5 * * * NOTE: This is for use in .EXEs * - in APP or PRJ modes you will see the VFP desktop flashing * (when it is made visible))

IoForm1 = createobject("MainForm") loFormi .show()
read events return


classes defined for this example *******
define class cmdQuit as commandbutton
Height = 27
Width = 84
Caption = “Quit”
Name = “cmdQuit”
PROCEDURE Click
*
a simple quit button for the purpose of this demonstration
clear events
release thisform
ENDPROC

enddefine

define class cmdReportPreview as commandbutton Height = 27
Width = 110 Caption = “View Report” Name = “cmdReportPreview” cReportName="ReportName" cReportCaption=”Report Preview”

PROCEDURE Click
if type(”thisform.llPreviewForm”)”L”

thisform.PrintPreview(this.cReportName,this.cReportCaption)
endif
ENDPROC

enddefine


DEFINE CLASS mainform as RPForm

Top = 2
Left = 23
Height = 390
Width = 549
Name = “MAINFORM”

ADD OBJECT TestQuit AS cmdQuit WiTH;
Top = 12,;
Left = 456

ADD OBJECT Previ AS cmdReportPreview WITH; Top = 12,;
Left = 50,; Caption= “View Reporti”, cReportName=”5odbc”, cReportCaption=”Preview of 50dbc report”


ADD OBJECT Prev2 AS cmdReportPreview WiTH;
Top= 12,;
Left = 200,;
Caption= “View Report2”,;
cReportName= 50dbc -
August 1997
cReportCaption=”VFP5 DBC Properties’

ENDOEFINE


the general class - can be used in any app that needs report
previews in the main app screen

DEFINE CLASS RPFORM AS form

ShowWindow = 2 && top-level form DoCreate = .T.
Caption = “Preview Window” MDlform = .t.
Name = “RPFORM” llScreenVisible=.f.
IlPreviewForm.t.
loPreviewForm=.NULL.
PROCEDURE INIT()
*
make sure the screen is not visible even if we call
this from the command window
this.llScreenVisible=_screen.visible _screen.visible.f.
this. IoPreviewFormcreateObject(”test”) ENDPROC


PROCEDURE RELEASE()
this.loPreviewForm.release()
screen.visible~this.llScreenVisibIe
ENDPROC

Procedure PrintPreview LPARAMETERS tcReportName,tcCaption local
lnOldTop,lnOldLeft,llVisible,lcWindowName,lcScreencaption,loForm2
if type(”tcReportName”)=”U”
return .f. endif llVisible=_screen.visible sc reen .vis ibi e.f.

loForm2this.loPreviewForm
if type(”tcCaption”)”C”
loForm2.caption=tcCaption
endif

*
save the old _screen values if we are calling this
from the VFP desktop
*
and move the screen out of sight
lnOldTop=_screen.top
lnOldLeft=_screen.Ieft
screen.top-1 000
screen.Ieft-1 000

*
you have to make the screen visible before moving the
preview toolbar and form
*
or else it will not transfer them correctly
lcScreencaption=_screen.caption
screen.caption=”Prepeari ng Report”
_screen.visible.t.

report preview form (tcReportName) nowait window test
activate window print in (thisform.name)

IcWindowName=left(loForm2.caption,at(”
“,loForm2.caption))
loForm2.caption=”default caption”
Page 6

6