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

Installing the Component into an existing Package

1Go to the Component menu, choose Install Component.

2Choose the Into existing package tab.

3Browse the Unit file name to locate the UCRPE32.PAS.

4Choose OK, then Yes to the prompts that follow.

The Crystal VCL should appear under the Data Access tab of the VCL Component palette.

Installing the Help file

There are a few ways to install context-sensitive Help within the BCB3 environment. By far the easiest method is to use the built-in OpenHelp installer:

1Copy the UCRPE32.HLP and UCRPE32.CNT to the BCB3 Help directory.

2Run BCB3 and go to the Help menu. Choose Customize (the OpenHelp installer can also be run outside the BCB3 environment by going to the BCB3 Bin directory and running OpenHelp.exe).

3With the Contents tab selected, right-click (or go to the Edit menu) and choose Add Files. Locate the UCRPE32.CNT file and add it to the list.

4With the Index tab selected, right-click (or go to the Edit menu) and choose Add Files. Locate the UCRPE32.HLP file and add it to the list.

5Choose File | Save Project.

Context-sensitive Help should now be available from the BCB IDE (choosing the F1 key while a property is selected should bring up the appropriate item in the UCRPE32.HLP file). Also, the Crystal Component Help will be available from the BCB Help file Contents list, and Index list. As well, pressing F1 on an item in the BCB code window should bring up the corresponding item in the Crystal Component Help file.

Programming Overview

The following topics are discussed in this section.

Introduction to the Object Inspector, Page 200

Changing Properties in the Object Inspector, Page 200

Changing Properties at Runtime, Page 200

Delphi Programmers introduction to the SCR Print Engine, Page 201

Dealing with SubClass Objects, Page 203

Consistent Code, Page 204

Using the Retrieve method, Page 205

Working with subreports, Page 206

Other Guidelines, Page 208

Seagate Crystal Visual Component Library

199

Introduction to the Object Inspector

Once you add the TCrpe component to a form in your project, build the connection between your Delphi application and the Crystal Report Engine by setting the Component's properties via the Object Inspector. Using the Object Inspector, you specify:

the name of the report you want to print in response to an application event,

the destination for that report (window, file, or printer),

the number of copies you want to print (if your report is going to the printer),

print file information (if your report is going to a file),

preview window sizing and positioning information (if your report is going to a window),

selection formula information (if you want to limit the records in your report),

sorting information, and

other related properties.

TCrpe component properties can be changed either at design time or at runtime. Note, however, some properties are available only at runtime. These properties will not appear on the Properties list in the Object Inspector. For a complete description of each property in the Crystal VCL Component, refer to Seagate Crystal Reports Technical Reference: Volume 4 - VCL Reference, which is available as a PDF file.

Changing Properties in the Object Inspector

To change the value for a property, click the property and then do the following:

If a text box appears next to the property name, type in a value for the property.

If a drop down list box appears next to the property name, click the arrow to open the drop down list and select a value from that list.

If a text box with an ellipsis (...) button appears next to the property name, click the button to reveal a dialog box where you can define your setting for the property.

Changing Properties at Runtime

You can set most of the properties for the TCrpe component at runtime by adding simple entries to your procedure code. Runtime property settings replace settings you make via the Object Inspector at design time.

The Execute property is used to actually process the report at runtime. This property can only be set at runtime, and it is the only means by which a report can actually be generated by the TCrpe component.

For information on how to set component properties at runtime, refer to your Delphi documentation. Developer’s online Help contains code examples for each of the TCrpe component properties. Search for the property you are interested to view these examples.

Seagate Crystal Visual Component Library

200

Delphi Programmers introduction to the SCR Print Engine

Programmers who are new to the Seagate Crystal Reports Print Engine will want to spend a few moments reading the next few paragraphs. After installing the Component, you should see the Seagate Crystal Reports component icon on the Data Access tab of the VCL palette. Start a new project, and add the Component to the form.

After adding the Component to the form, there are only two basic calls that need to be made in order to run a report. First add a Button to your new form. Double click the button to start an OnClick event in the code for the form. Inside the OnClick event, type the following two lines:

Crpe1.ReportName := 'c:\MyReport.rpt';

Crpe1.Execute;

Change 'c:\MyReport.rpt' to point to a valid Crystal Report file that exists on your computer. Now compile the new Project and run it. When it appears, click on the button. If all goes well, you should see a Crystal Report appear in the runtime Preview Window.

You will want to remember a basic rule at this point: always set the ReportName property first. The reason for this is that when the value of ReportName changes, most of the other properties are cleared. This is more fully explained later in this chapter in the Programming Tips section.

The next property you may want to experiment with is the Output property. By default this is set toWindow, but you can also set it toPrinter, or toExport. This can be done in code or with the Object Inspector. If you are using it in code, be sure to write it before the Execute command, or it will be ignored until the next Execute is called:

Crpe1.ReportName := 'c:\MyReport.rpt';

Crpe1.Output := toPrinter;

Crpe1.Execute;

The following list shows which properties control the options that are available for each Output type:

toWindow

toPrinter

toExport

 

 

 

WindowButtonBar

Printer

Export

 

 

 

WindowSize

PrintOptions

ProgressDialog

WindowState

ProgressDialog

 

 

 

 

WindowStyle

 

 

 

 

 

WindowZoom

 

 

 

 

 

Seagate Crystal Visual Component Library

201

Once you are familiar with these options, you will want to consider changing the other properties that affect how the report processes. Many of the options that are used to build a report can be changed via the runtime Print Engine. The following list gives the name of the option in the Crystal Reports Designer, and its equivalent in the Crystal Reports component:

Crystal Reports

Crystal Reports VCL Component

 

 

 

 

Database Location

Tables

 

 

Export

Export

Email

Export.Email

 

 

Font

SectionFont

 

 

Format Section

SectionFormat

 

 

 

AreaFormat

 

SectionMinHeight

 

 

Formulas

Formulas

 

 

Graph features

GraphType

 

 

 

GraphText

 

 

 

GraphOptions

 

GraphData

 

 

Grouping

GroupCondition

 

 

LogOn Information

Connect

 

 

 

LogOnInfo

LogOnServer

LogOnServer

 

 

Page Setup / Page Margins

Margins

 

 

Parameter Fields

ParamFields

 

 

Passwords: MS Access

SessionInfo

Passwords: Paradox

Tables

Print Date

PrintDate

 

 

Printer Setup

Printer

 

 

PrintOptions

 

 

 

Report Comments

SummaryInfo

Report Title

ReportTitle

 

 

Selection Formula: Group

GroupSelection

 

 

Selection Formula: Record

Selection

 

 

Sort Records

SortFields

 

GroupSortFields

 

 

SQL Query

SQL

 

 

Stored Procedure Parameters

Params

 

 

Seagate Crystal Visual Component Library

202

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