Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ReportListener example
Message
From
06/08/2008 16:23:59
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Title:
ReportListener example
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01337045
Message ID:
01337045
Views:
98
I am trying to start learning ReportListener. I found the following sample code:
* Example, by Garrett Fitzgerald
* http://blog.donnael.com/2004/06/vfp9-report-sample/

CREATE CURSOR crsrFontList ( ;
 cFont char(32))

llGotFonts = AFONT(laFonts)
FOR i = 1 TO ALEN(laFonts)
 INSERT INTO crsrFontList VALUES (laFonts(i))
ENDFOR

CREATE REPORT fontList FROM DBF("crsrFontList")

loListen = CREATEOBJECT("myFontListener")

REPORT FORM fontList PREVIEW OBJECT loListen 

DEFINE CLASS myFontListener as ReportListener
 ListenerType = 1

 PROCEDURE EvaluateContents
  LPARAMETERS nFrxRecno, oObjProperties

  oObjProperties.FontName = ALLTRIM(cFont)
  oObjProperties.Reload = .T.
 ENDPROC
ENDDEFINE
Now, it is easy to see how an object's .FontName is dynamically changed, and looking at the help file it should also be easy to change additional properties, such as .FontSize or color.

Now my question is, how do I distinguish different objects on a report? This sample report happens to have only one object; but in practice, I may want one particular field, and not all fields, to be bold or red if an amount is negative, for example.

A parameter is passed that indicates the field in the FRX file, but this doesn't seem very practical; it might change if objects are added for example.

TIA,

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Next
Reply
Map
View

Click here to load this message in the networking platform