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

Example

The following code illustrates a simple use of the Execute method to run a Report to Window:

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

Crpe1.Output := toWindow;

Crpe1.Execute

ExTimeStr method

Declaration

function ExTimeStr(sValue: string; var sHour, sMin, sSec: string ): Boolean;

Description

ExTimeStr is used internally in the Crystal component but has been exposed for general purpose use. It takes a Time string value and passes the individual parts into the Hour/Min/Sec var parameters.

var

 

sTime

: string;

sH,sN,sS : string; begin

sTime := '12:22:23';

if Crpe1.ExTimeStr(sTime, sH, sN, sS) then ShowMessage('H/M/S strings extracted successfully!');

end;

{sH = '12'; sN = '22'; sS = '23'}

FloatingToStr method

Declaration

function FloatingToStr(const fValue: double): string;

Description

FloatingToStr is used internally in the Crystal component but has been exposed for general purpose use. It takes a Floating point numeric value and returns the value as a string.

fValue := 1.23;

str1 := Crpe1.FloatingToStr(fValue); {str1 now looks like this: '1.23'}

VCL Reference

144

Focused method

Declaration

function Focused: boolean;

Description

Determines if the Crystal Preview window has focus or not (i.e. is it the uppermost window on the screen, the one that receives keyboard and mouse input). This method can be used in concert with the SetFocus method.

Example

This code example checks to see if the Crystal Preview Window is the topmost window. If not, it makes it the topmost:

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

if not Crpe1.Focused then Crpe1.SetFocus;

GetPathFromAlias method

Declaration

function GetPathFromAlias(const Value: string): string;

Description

The GetPathFromAlias function is used internally in the Crystal component for converting BDE Aliases that are passed into the Path property of the Tables object. It has been made available as a general purpose function because some developers use BDE Aliases to store other path information, such as the directory that Reports are stored in. The BDE Alias must be passed in with colons on each side, i.e.: ':MyAlias:' and will return a standard pathname string with trailing backslash.

VCL Reference

145

Example

The following code illustrates the use of the GetPathFromAlias function to retrieve the path that the Reports are stored in:

var

sPath: string; begin

sPath := Crpe1.GetPathFromAlias(':MyReportsAlias:'); Crpe1.ReportName := sPath + 'Report1.rpt'; Crpe1.Execute;

end;

GetToken method

Declaration

function GetToken(var s: string; const sDelimiter: string): string;

Description

The GetToken function is used internally in the Crystal component, mostly for parsing date strings. It has been made available as a general purpose function and will take a string, search for a delimiter character or string of characters, and return the string up to the delimiter. Since the original string is passed as var it will be modified in the function: the returned string and delimiter will be removed from the original string. Because of this, GetToken can be used multiple times on the same string to obtain the various delimited parts.

Example

The following code illustrates the use of the GetToken function to parse a date string (YYYY-MM-DD):

function GetDate(DateStr: string): TDateTime; var

wYear,

wMonth,

wDay : Word; begin

{Extract Year, Month, Day}

wYear := StrToInt(Crpe1.GetToken(DateStr, '-')); {The DateStr now has MM-DD; wYear has YY}

wMonth := StrToInt(Crpe1.GetToken(DateStr, '-')); {The DateStr now has DD; wMonth has MM}

wDay := StrToInt(DateStr);

Result := EncodeDate(wYear, wMonth, wDay); end;

VCL Reference

146

GetVersionInfo method

Declaration

function GetVersionInfo(const Filename: string; const Key: string ): string;

Description

GetVersionInfo is used internally in the Crystal component but has been exposed for general purpose use. It takes a Filename (usually EXE or DLL) and a Key value to look for and returns a string with the actual value. Key values can be things like:

FileVersion

FileDescription

LegalCopyright

Comments

CompanyName

InternalName

OriginalFilename

ProductName

ProductVersion

str1 := Crpe1.GetVersionInfo('CRPE32.DLL', 'FileVersion'); {str1 now looks something like this: '7.0.1.192'}

HideWindow method

Declaration

procedure HideWindow;

Description

The HideWindow method makes the Preview Window invisible. Use ShowWindow to make it appear again.

Example

The following example illustrates the HideWindow method:

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

Crpe1.HideWindow; {...after a while...} Crpe1.ShowWindow;

VCL Reference

147

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