Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
172
Добавлен:
11.05.2015
Размер:
4.73 Mб
Скачать

Description

The PrintJob is automatically opened as required by the Crystal component. If you want to force the Job to open at an earlier time, such as right after the ReportName is assigned, it can be done through this method.

What do you mean by "Open the PrintJob"?

What this means is that the Crystal Reports Print Engine DLL loads the Report file into memory. Initially when the ReportName property of the Crystal component is assigned a value, space is allocated internally in the component, but the Print Engine does not yet need to load the Report, so the Print Job is not opened. As soon as one of the Retrieve methods, or the Execute method is called, then the Print Engine loads the Report, and processes it accordingly.

In the case of a Retrieve call, the Print Engine passes the desired values back to the Crystal component. In the case of an Execute call, the Crystal component values are passed to the Print Engine, and then the Print Engine runs the Report with those new values.

Example

The OpenJob method is used to force the PrintJob open after the ReportName is set. Otherwise, OpenJob would occur automatically when Execute is called, or any of the Retrieve methods:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.OpenJob;

Crpe1.Output := toWindow;

Crpe1.Execute;

PrintWindow method

Declaration

procedure PrintWindow;

Description

The PrintWindow procedure sends the Report that is displayed in the current Preview Window to printer. It is particularly useful when building a custom button bar to simulate the Print Button that appears on the Preview Window button bar.

Example

The following example runs a Report to Window. When a button on the application is pressed, the Window is printed:

Crpe1.ReportName := 'MyReport.rpt';

Crpe1.Output := toWindow;

Crpe1.Execute;

{When an Print button is pressed do...} Crpe1.PrintWindow;

VCL Reference

152

ReportWindowHandle method

Declaration

function ReportWindowHandle: integer;

Description

The ReportWindowHandle property returns the current Window Handle number of an open Preview Window. It is useful for determining when the window is closed. For this purpose, the OnWindowClose event can also be used.

Example

The following example checks the ReportWindowHandle property to see when the Preview Window is closed. When the window is closed, the application Form closes also:

Crpe1.ReportName := 'MyReport.rpt'; Crpe1.Output := toWindow; Crpe1.Execute;

while Crpe1.ReportWindowHandle > 0 do Application.ProcessMessages;

Close;

RetrieveDetailCopies method

Declaration

function RetrieveDetailCopies: boolean;

Description

RetrieveDetailCopies returns the number of Detail Copies specified in the currently open Report and populates the DetailCopies property with the value. This call can also be made to a Subreport.

Example

The following example retrieves the Detail Copies from a Report:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.RetrieveDetailCopies;

ShowMessage(IntToStr(Crpe1.DetailCopies));

VCL Reference

153

RetrieveFieldMapping method

Declaration

function RetrieveFieldMapping: boolean;

Description

This function returns the current FieldMapping setting from a Report and updates the FieldMapping property accordingly.

RetrieveReportTitle method

Declaration

function RetrieveReportTitle: boolean;

Description

RetrieveReportTitle returns the Report Title from the currently open Report and populates the ReportTitle property with the value. This call can also be made to a Subreport.

Example

The following example retrieves the Report Title from a Report:

Crpe1.ReportName := 'C:\Report1.rpt';

Crpe1.RetrieveReportTitle;

ShowMessage(Crpe1.ReportTitle);

RetrieveWindowState method

Declaration

procedure RetrieveWindowState;

Description

RetrieveWindowState retrieves the current state of the open Preview Window and updates the WindowState property with this value.

VCL Reference

154

Example

The following example uses the RetrieveWindowState call to obtain the state of the open Preview Window:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Output := toWindow; Crpe1.Execute;

{...after a while...} Crpe1.RetrieveWindowState;

SectionCodeToStr method

Declaration

function SectionCodeToStr(const Value: smallint): string;

Description

The SectionCodeToStr function is used internally in the Crystal component for the SectionAsCode properties of the following objects:

AreaFormat

AreaFormatFormulas

SectionFormat

SectionFormatFormulas

SectionFont

SectionHeight

GraphType

GraphText

GraphOptions

GraphData

It takes a Print Engine Section Code number (i.e. 3026) and converts it to the Section naming convention that the component uses (GH1b). It is mainly included as a public function for testing purposes. The StrToSectionCode method does the opposite conversion.

See: About Section Names, Volume 1, Chapter 7, for more details.

Example

The following example shows the syntax of the SectionCodeToStr function:

var

sTmp: string; begin

sTmp := Crpe1.SectionCodeToStr(3000); {sTmp will equal 'GH1a'}

end;

VCL Reference

155

Соседние файлы в папке crystal