This script is called when the user previews a report. You can use this to, for example, add a button to the Preview window's toolbar that performs an action when clicked.

Parameters
A reference to the Stonefield Query Application object, a reference to the Preview window, and a reference to a Report object for the report.

Return Value
Any value (Stonefield Query ignores the return value).

Example
Here's an example that adds a button to the Preview window's toolbar that displays the raw data for the report in a window when clicked.

Visual FoxPro

lparameters toApplication as SQApplication, toPreview, toReport as Report
if type('toPreview.Toolbar.cmdAction') <> 'O'
  try
    compile MyClasses.prg
  catch
  endtry
  toPreview.Toolbar.NewObject('cmdAction', 'MyButton', 'MyClasses.prg')
  toPreview.Toolbar.cmdAction.Visible = .T.
  toPreview.Toolbar.cmdAction.Left    = toPreview.Toolbar.cmdQuit.Left
  toPreview.Toolbar.cmdAction.Top     = toPreview.Toolbar.cmdQuit.Top
  toPreview.Toolbar.cmdQuit.Left      = toPreview.Toolbar.cmdQuit.Left + 30
endif
return .T.

The Preview window has a Toolbar member that's the toolbar for the window. This code checks whether a button named cmdAction has already been added to the toolbar (because the preview window may already be open displaying another report so the button may have been added before) and if not, adds a button from the MyButton class in MyClasses.prg. The code makes the button visible and positions it before the Close button (cmdQuit).

Here's the MyButton class, contained in MyClasses.prg:

define class MyButton as CommandButton
  Height = 22
  Width = 22
  Picture = 'mybutton.bmp'
  Caption = ''
  SpecialEffect = 2
  Name = 'mybutton'

  procedure Click
    loPage = Thisform.GetCurrentPage()
    SQApplication.OpenForm('Browser', 'Report Results', ;
      loPage.oReport.cCursor)
  endproc
enddefine

The Click method of this button gets a reference to the currently displayed page (the Preview window can display more than one report in different tabs). The page has an oReport member that's a reference to the report displayed. The report object has a cCursor member that contains the name of the result set for the report. This code then uses the built-in Browser dialog to display the contents of the result set.

See also

Scripts