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

WindowCursor Example

The example below sets the Mouse Cursor to a Magnifying Glass when it passes over a Group Area on the Preview Window:

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

Crpe1.WindowCursor.GroupArea := wcMagnify;

Crpe1.Output := toWindow;

Crpe1.Execute;

WindowCursor Properties

WindowCursor DetailArea property, Page 696

WindowCursor DetailAreaField property, Page 697

WindowCursor Graph property, Page 697

WindowCursor GroupArea property, Page 698

WindowCursor GroupAreaField property, Page 698

WindowCursor Methods

WindowCursor Clear method, Page 699

WindowCursor CopyFrom method, Page 700

WindowCursor Create method, Page 700

WindowCursor Retrieve method, Page 700

WindowCursor Send method, Page 701

WindowEvents

Declaration

property WindowEvents: boolean;

Description

The WindowEvents property activates the Preview Window callback events. These callback events allow Delphi to respond to actions that take place on the Crystal Reports Preview Window, such as button clicks and drilldown events. The various events listed on the Events page of the Object Inspector, and are prefixed with "w":

wOnActivateWindow wOnCancelBtnClick wOnCloseBtnClick wOnCloseWindow

VCL Reference

123

wOnDeActivateWindow wOnDrillDetail wOnDrillGroup wOnExportBtnClick wOnFirstPageBtnClick wOnGroupTreeBtnClick wOnLastPageBtnClick wOnNextPageBtnClick wOnPreviousPageBtnClick wOnPrintBtnClick wOnPrintSetupBtnClick wOnReadingRecords wOnRefreshBtnClick wOnRightMouseClick wOnSearchBtnClick wOnShowGroup wOnStartEvent wOnStopEvent wOnZoomLevelChange

The WindowEvents property should be set before Execute is called.

NOTE: WindowEvents are only available with SCR 6 or higher.

WindowEvents Example

This code activates the Preview Window callback events:

Crpe1.ReportName := 'Report1.rpt';

Crpe1.Output := toWindow;

Crpe1.WindowEvents := True;

Crpe1.Execute;

WindowParent

Declaration

property WindowParent: TCrWinControl;

Type

TCrWinControl = TWinControl;

Description

WindowParent is a run-time only property that can be used to attach the Crystal Preview Window to a Delphi Form. This is useful when you want to create a custom button bar, or make the Crystal window an MDI child.

VCL Reference

124

Dealing with MDI Forms

There are two options when using an MDI Form:

1.With version 7.x of the VCL, the WindowParent property now has built-in support for MDI forms. If it detects that the Form specified in the WindowParent property is an MDI Form (FormStyle = fsMDIForm), it will create a Delphi MDI Child Form, and attach the Crystal Preview Window to that child. In this way, Delphi's built-in support for MDI child windows is preserved. Resizing of the Crystal Preview Window with the MDI Child is automatically handled inside the Crystal VCL. The child form is freed when the MDI Child window is closed.

2.Programmer's may want more control over the appearance and behavior of their MDI Child forms, beyond what is offered via option 1. In that case, we recommend that you make the Parent and Child Forms in Delphi, attach the Crystal component to the Child Form, and set the WindowParent of the component to the Child Form. To set the WindowParent property, simply pass it the name of the Form or Panel desired. The resize event will have to be coded, so that the Crystal Preview Window resizes with the Child form:

procedure TChildForm1.OnResize(Sender: TObject); begin

SetWindowPos(Crpe1.ReportWindowHandle, HWND_TOP, 0, 0, ChildForm1.ClientWidth, ChildForm1.ClientHeight, SWP_NOZORDER);

end;

For a working example of option 2, see our MDI32 Sample Application.

NOTE: Important! When attaching the Crystal Preview window to another Form via the WindowParent property, be careful to make sure the Crystal Window is closed before the Form it is attached to is destroyed. This will not be a problem if the VCL is attached to the Child Form, since it will be destroyed with the Child. But if the VCL component is still in existence when the Child Form is destroyed, an Access Violation will occur when the VCL is finally freed, or possibly when the Print Job closes. One way to avoid the error is to put a Crpe1.CloseWindow call in the Child Form's OnClose event:

procedure TChildForm1.OnClose(Sender: TObject; var Action: TCloseAction); begin

Crpe1.CloseWindow;

Release; end;

WindowParent Example

The code below makes the Crystal Preview Window a child of Form1:

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

Crpe1.WindowState := wsNormal;

Crpe1.Output := toWindow;

Crpe1.WindowStyle.BorderStyle := bsNone;

VCL Reference

125

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