PrintCachedPages Method (TMM)

Visual FoxPro 9.0 SP2
Back to TMM Index
This is a corrected version of a new-in-SP2 CHM Method topic.


You can use PrintCachedPages to print whenever the ReportListener assisting a report run is in all pages at once mode, as specified by a .ListenerType value of 1 or 3.

As with OnPreviewClose(.T.), when you invoke this method the Report Engine is aware of the readwrite member values in CommandClauses.

Caution note Caution

The SP2 CHM topic for this new-in-SP2 method teaches you about using the shipping Report Preview Application, but little about the reasons for the addition of, or behavior of, the base method itself.

The shipping Report Preview application is responsible to replicate, as nearly as possible, the behavior of the pre-VFP 9 internal Report Preview. In RTM and SP1, REPORTPREVIEW.APP could not easily replicate the internal Preview behavior with regard to the Print button on its toolbar when a REPORT FORM... NOWAIT command was issued, because its only method of printing was attached to the OnPreviewClose method. Insofar as PrintCachedPages addresses that requirement, the SP2 CHM topic is correct to make some reference to  the shipping Report Preview application.

However, the requirement to replicate pre-VFP 9 Preview is hardly the extent of the value of this new feature.

You can use the PrintCachedPages method whether or not you have a NOWAIT clause on your REPORT FORM command, and even when no PREVIEW is involved -- a fact that should be evident in the example in this TMM docoid.



In the following example, there is no automatic preview behavior, because the value of the ReportListener.ListenerType property is 3.

When you invoke PrintCachedPages after the REPORT FORM command, the print setup dialog comes up as part of the printing process, because you have previously set CommandClauses.Prompt to .T.. Because you have also set CommandClauses.PrintRangeFrom and CommandClauses.PrintRangeTo, the print setup dialog appears with its Page Range option button pre-set to Pages: 5-6.

LOCAL ox as ReportListener

ox = CREATEOBJECT("reportlistener")
ox.ListenerType = 3
WITH ox.CommandClauses
 .Prompt = .T.
 .PrintRangeFrom = 5
 .PrintRangeTo = 6

See AlsoSee Also