Creating a custom preview window

Top  Previous  Next

FastReport displays reports in the standard preview window. If for any reason this is not satisfactory then a custom preview form can be created. The “TfrxPreview” component from the FastReport component palette was designed for this purpose. To display a report the “TfrxReport.Preview” property should be directed to this “TfrxPreview” component.

 

There are typically two problems when using the “TfrxPreview” component. It does not always respond to key presses (arrows, PgUp, PgDown etc) and does not respond to the mouse wheel (if present). To make “TfrxPreview” respond to keys pass the focus to it (for example in the OnShow event handler of the form):

 

frxPreview.SetFocus;

 

To make “TfrxPreview” respond to mouse scrolling an “OnMouseWheel” event handler has to be created and the “TfrxPreview.MouseWheelScroll” method called in this handler:

 

procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState;

                               WheelDelta: Integer;

                               MousePos: TPoint; var Handled: Boolean);

begin

 frxPreview1.MouseWheelScroll(WheelDelta);

end;