If I call REPORT FORM from a form, foxpro prints what appears to be debug the bug returns even with the fixes to the report listener class. Visual FoxPro General. Visual FoxPro Dear friends, I have used Report listener with its quietmode.t. to send output of the report to html file. vfp 9 introduces a new reporting system based on listeners additive * create a report listener object local loreportlistener loreportlistener.

Author: Kazicage Shajinn
Country: Poland
Language: English (Spanish)
Genre: Medical
Published (Last): 11 July 2018
Pages: 250
PDF File Size: 11.37 Mb
ePub File Size: 1.55 Mb
ISBN: 515-8-86823-440-4
Downloads: 13528
Price: Free* [*Free Regsitration Required]
Uploader: Zuluhn

Doug has spoken at every Microsoft FoxPro Developers Conference DevCon since and at user groups and developer conferences all over the world. His Web sites are http: Among the new and improved features in Microsoft Visual FoxPro 9, you’ll find the ability to extend the behavior of the reporting system when reportlistenef reports. In this article, you’ll learn about Visual FoxPro 9’s report listener concept, how it receives events as a report runs, and how you can create your own listeners to provide different types of output in addition to print and preview.

There are incredible improvements in the Visual FoxPro 9 reporting system. Of several aspects, I’ll discuss just one in this article: The reporting engine in Rfportlistener FoxPro 9 splits responsibility for reporting between the report engine, which now just deals repprtlistener data handling and object positioning, and a new object known as a report listener, which handles rendering and output.

The Visual FoxPro development team had several goals in mind when they worked on the runtime improvements, including:. You have access to both the old report engine and the new one, so you can run reports under either engine as you see fit.

But once you see the benefits of the new report engine, you won’t want to go back to old-style reporting. Before Visual FoxPro 9, the report engine was monolithic; it handled everything and with a few exceptions user-defined function, expressions for OnEntry and OnExit of bands, and so forthyou couldn’t interact with it during a report run. The new reporting engine splits responsibility for reporting between the report engine, which now deals only with data handling and object positioning, and a new object known as a report listener, which handles rendering and output.

Because report listeners are classes, we can now interact with the reporting ffoxpro in ways we could only dream of before. Report listeners produce output in two ways. Page-at-a-time mode renders a page and outputs it, then renders and outputs the next page, and so on.

This mode is used when a report is printed. In all-pages-at-once mode, the report listener renders all the pages and caches them in memory.

Reportlisrener then outputs these rendered pages on demand. This mode is used when a report is previewed. Microsoft refers to this as object-assisted reporting. A report listener is an object that provides new-style reporting behavior. If you’d rather not instantiate a listener manually, you can have Visual Reportlistdner do it for you automatically by specifying a report type:. The defined types are 0 for outputting to a printer, 1 for previewing, 2 for page-at-a-time mode but not to send the output to a printer, 3 for all-pages-at-once mode but not invoke the preview window, 4 for XML output, and 5 for HTML output.

Other, user-defined, types can also be used. APP in the Visual FoxPro home directory by default is called to determine which listener class reporglistener instantiate for the specified type. It does this by looking for the listener type in a listener registry table built into the APP although you can also tell it to use an external table. If it finds the desired class, it instantiates the class and gives a reference to the listener object to the reporting engine.

During the run of a report, Visual FoxPro exposes reporting events to objects based on the ReportListener base class as they happen. VCX, which contains some subclasses of ReportListener that have more functionality than the base class. It’s possible you may want to use more than one report listener when running a report. For example, if you want to both preview a report and output it to HTML at the foxprp time, more than one report listener must be reportliatener.


Here’s how these listeners can be chained together:. As the report engine raises report events, the lead listener calls the appropriate methods of its successor, the successor calls the appropriate methods of its successor, and so reportljstener down the chain. This type of architecture reportlistdner known as a chain of responsibility, as any listener repotlistener the chain can foxrpo to take some action or pass the message on to the next item in the chain.

You pass this method the name of a report and optional report clauses to use such reportlistenwr the RANGE clause and a reference to another listener object. The RemoveReports method removes all reports from the collection. RunReports runs the reports; pass it.

VFP Reporting System Fundamentals – Part 2

Here’s an example that runs two reports as if they were a single one:. These listeners are built into ReportOutput.

However, this doesn’t give you any control over the name of the file to create or other settings. When you specify type 5, ReportOutput. XML from the MyReport report, containing only the data. In this case, the XMLListener class type 4 is used.

Working with reports,olecontrols and listener class

Both of these listener classes have additional properties you can use to further control the output. I recommend a look at the Visual FoxPro documentation reportkistener details. Because report listeners are a class, you can create subclasses that alter the behavior of the reporting system when a report runs. The key to changing the way a field appears in a report is the EvaluateContents method. For example, one thing I’ve always wanted is a way to dynamically format a field at runtime.

Under some conditions, I may want a field to print with red text, and under others, I want it in black. Perhaps a field should sometimes be bold and the rest of the time not. This method fires for each field object just before it’s rendered, and gives the listener the opportunity to change the appearance of the field.

Extending the Reporting System at Run Time

The first parameter is the FRX record number for the field object being processed and the second is an object containing properties with information about the field object. See the Visual FoxPro Help file for a list of the properties this object contains. You can change any of these properties to change the appearance of the field in the report.

If you do so, set the Reload property of the object to. Listing 1 shows some code TestDynamicFormatting. These effects are applied by effect handler objects, which are stored in a collection in the oEffectsHandlers property of EffectsListener.

Each effect handler object handles a single effect. As the report is processed, the listener needs to determine which fields will have effects applied to them. It does that in the EvaluateContents method by looking at each field as it’s about to be rendered.

EvaluateContents calls SetupEffectsForObject, which calls the GetEffect method of each effect handler to let it decide whether to apply an effect to the field.

If a particular handler is needed for the field, a reference to the handler is added to a collection of handlers that processes the field as a field may have more than one effect applied to it. However, EvaluateContents fires for every field in every record, and there really isn’t a need to check for the effects more than once for a particular field doing so would slow down the performance of reporglistener report.

If the first column of the array is the default. After determining whether there are any effects to be applied to the field, EvaluateContents then goes through the collection of effect handlers for the field, calling the Execute method of each one to have it do whatever is necessary.


DynamicForeColorEffect is one of the effect handlers. It looks for repirtlistener directive in the USER memo of a field in the report with the following format:. You can access the USER memo of an object in a report from the Other page of the properties dialog box for that object.

DynamicStyleEffect uses a similar directive to change the font style.

The style to use must be a numeric value: You aren’t limited to changing the appearance of a field? The Render method of ReportListener is responsible for drawing each object on the report page. You can override this method to perform various types of output. The code shown in Listing 2taken from TestColumnChart. FRX report, shown in Figure 2and creates the output shown in Figure 3.

That’s partly due to Print When clauses on the fields that prevent them from printing, but the biggest reason is that the listener class used for this report, ColumnChartListener, replaces the shape object in the Summary band with a column chart.

Let’s see how this listener does that. The Init method of ColumnChartListener initializes the aColumnColors array to the color to use for each column in the chart. If you want to use a different set of colors, you can subclass ColumnChartListener or store a different set of colors in the array after you instantiate ColumnChartListener.

Note that only eight colors are defined; if there are more than eight columns in the chart, the listener uses the same colors for more than one bar.

The only complication is that the handle changes on every page, so the BeforeBand method, which fires just before a band is processed, calls the SetHandle method of the GPGraphics object to give it the handle when the title or page header bands are processed.

As the report is processed, the listener needs to determine where the labels and values for the chart come from. As with the EffectListener class I discussed earlier, there isn’t a need to check the USER memo more than once, so the same type of mechanism?

If the listener hasn’t checked the USER memo for the field being rendered yet, EvaluateContents does that, setting flags in the array indicating whether the field is used for labels or values, and setting the first column of the array to.

If the field is used for either labels or fields, EvaluateContents updates the aValues array accordingly. AdjustObjectSize is similar to EvaluateContents except it fires for shapes rather than fields.

As with EvaluateContents, the listener only needs to check once, so it uses similar logic. The Render method is responsible for drawing an object on the report. Otherwise, the object is drawn normally. It calls the DrawLine method to draw the vertical and horizontal borders for the chart, and then goes through the aValues array, drawing a column for each value using DrawRectangle and filling it with the appropriate color via FillRectangle.

Some drawing attributes come from values in custom properties, making charting more flexible. See the comments for these properties near the start of the Listing 2. Microsoft has blown the lid off the Visual FoxPro reporting system!

By passing report events to ReportListener objects, they’ve allowed us to react to these events to do just about anything we wish, from providing different types of output to dynamically changing the way objects are rendered.

I can hardly wait to see the type of things the Visual FoxPro community does with these new features.

There are three datasessions involved during a report run. The first is the datasession in which the ReportListener is instantiated. This is often the default datasession. The third datasession is the one in which the report’s data resides.