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

Example

The following example runs a Report to Window. When the Window is closed, the Print Job is also closed:

procedure TForm1.RunReport; begin

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

end;

procedure TForm1.Crpe1OnWindowClose(Sender: TObject); begin

Crpe1.CloseJob; end;

WindowEvents

The Window Events consist of 23 events associated with the Crystal Reports Preview Window. These Window Events are triggered when certain actions take place on the Preview Window and are only enabled if the WindowEvents property is set to True.

wOnActivateWindow, Page 177

wOnCancelBtnClick, Page 178

wOnCloseBtnClick, Page 178

wOnCloseWindow, Page 179

wOnDeActivateWindow, Page 180

wOnDrillDetail, Page 181

wOnDrillGroup, Page 182

wOnExportBtnClick, Page 184

wOnFirstPageBtnClick, Page 185

wOnGroupTreeBtnClick, Page 185

wOnLastPageBtnClick, Page 186

wOnNextPageBtnClick, Page 187

wOnPreviousPageBtnClick, Page 188

wOnPrintBtnClick, Page 189

wOnPrintSetupBtnClick, Page 190

wOnReadingRecords, Page 191

wOnRefreshBtnClick, Page 192

VCL Reference

176

wOnRightMouseClick, Page 192

wOnSearchBtnClick, Page 195

wOnShowGroup, Page 196

wOnStartEvent, Page 197

wOnStopEvent, Page 198

wOnZoomLevelChange, Page 199

wOnActivateWindow

wOnActivateWindow takes place just before the Preview Window becomes active, or receives the focus. This event passes the following variables:

WindowHandle - The Handle to the current Preview Window.

Cancel - A variable that can be set to True to cancel the normal Preview Window response to the Event.

Declaration

property wOnActivateWindow: TCrpeGeneralPrintWindowEvent;

Type

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Remarks

You must be using Crystal 6.0 or higher to use Window Events.

Example

The following procedure illustrates the wOnActivateWindow Event:

procedure TForm1.Crpe1wOnActivateWindow(WindowHandle: Integer; var Cancel: Boolean);

begin

with Memo1.Lines do begin

Add('wOnActivateWindow Event:'); Add(' - Window was Activated ');

Add(' - WindowHandle: ' + IntToStr(WindowHandle)); Add('');

end; end;

end;

VCL Reference

177

wOnCancelBtnClick

wOnCancelBtnClick takes place after the Cancel button on the Preview Window button bar is clicked but before canceling the printing or reading of the database. This event passes the following variables:

WindowHandle

The Handle to the current Preview Window.

 

 

Cancel

A variable that can be set to True to cancel the normal Preview Window

 

response to the Event.

 

 

Declaration

property wOnCancelBtnClick: TCrpeGeneralPrintWindowEvent;

Type

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

Remarks

You must be using Crystal 6.0 or higher to use Window Events.

Example

The following procedure illustrates the wOnCancelBtnClick Event:

procedure TForm1.Crpe1wOnCancelBtnClick(WindowHandle: Integer; var Cancel: Boolean);

begin

with Memo1.Lines do begin

Add('wOnCancelBtnClick Event:'); Add(' - Cancel Button clicked ');

Add(' - WindowHandle: ' + IntToStr(WindowHandle)); Add('');

end; end;

wOnCloseBtnClick

wOnCloseBtnClick takes place after the Close button on the Preview Window button bar is clicked, but before the Preview Window is closed. This event passes the following variables:

WindowHandle

The Handle to the current Preview Window.

 

 

ViewIndex

Specifies which View is going to be closed. The View is the current tab on the

 

Preview Window, which could be the main Preview tab, or one of the open

 

drill-down tabs. The Preview tab is numbered 0, and the drill-down tabs are

 

numbered from left to right in order.

 

 

Cancel

A variable that can be set to True to cancel the normal Preview Window

 

response to the Event.

 

 

VCL Reference

178

Declaration

property wOnCloseBtnClick: TCrpeCloseButtonClickedEvent;

Type

TCrpeCloseButtonClickedEvent = procedure(WindowHandle: HWnd; ViewIndex: Word; var Cancel: Boolean) of object;

Remarks

You must be using Crystal 6.0 or higher to use Window Events.

Example

The following procedure illustrates the wOnCloseBtnClick Event:

procedure TForm1.Crpe1wOnCloseBtnClick(WindowHandle: Integer; ViewIndex: Word; var Cancel: Boolean);

begin

with Memo1.Lines do begin

Add('wOnCloseBtnClick Event:'); Add(' - Close Button clicked ');

Add(' - WindowHandle: ' + IntToStr(WindowHandle)); Add(' - ViewIndex: ' + IntToStr(ViewIndex)); Add('');

end; end;

wOnCloseWindow

wOnCloseWindow takes place just before the Preview Window is closed. This event passes the following variables:

WindowHandle

The Handle to the current Preview Window.

 

 

Cancel

A variable that can be set to True to cancel the normal Preview Window

 

response to the Event.

Declaration

property wOnCloseWindow: TCrpeGeneralPrintWindowEvent;

Type

TCrpeGeneralPrintWindowEvent = procedure(WindowHandle: HWnd; var Cancel: Boolean) of object;

VCL Reference

179

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