New "Onbeforepreview" event in LazReport
Original Reporter info from Mantis: zgabrovski
-
Reporter name: Zdravko Gabrovski
Original Reporter info from Mantis: zgabrovski
- Reporter name: Zdravko Gabrovski
Description:
In the current version of LazReport, the developer has no control over the standard "Preview report" form.
In my case I am developing a plugin dll library, which uses lazrRepor in DLL as a non-modal form. I need to set form style of the standard preview form to "fsStayOnTop" and register the form in object list, that I will use later on to free the form objects (as it is known, it is not possible to set action=caFree in non modal form in dll, it raises AV).
To solve all the cases, I just add a new event handler called "OnBeforePreview" in LazReport. It will pass by reference already created preview form, which will give an option to developer to modify it.
New Event Hadler type:
TBeforePreviewFormEvent = procedure( var PrForm : TfrPreviewForm ) of Object;
Nee variable:
fOnBeforePreview : TBeforePreviewFormEvent;
And new property:
property OnBeforePreview : TBeforePreviewFormEvent read fOnBeforePreview write fOnBeforePreview;
And small modification in procedure TfrReport.ShowPreparedReport:
if Assigned( OnBeforePreview ) then
OnBeforePreview( p );
and a sample of usage in my code:
procedure TDataModule2.frReport1BeforePreview(var PrForm: TfrPreviewForm);
begin
PrForm.FormStyle := fsStayOnTop; // Changle preview form style; In DLL if it if fsNormal, the user can hide the form
PrForm.OnClose := @FormCloseHandler; // I am using this to add a form object to object list for free the non-modal forms created in dll
end;
Steps to reproduce:
Enhancement
Mantis conversion info:
- Mantis ID: 37794
- OS: all
- OS Build: all
- Build: trunk
- Platform: all
- Version: 2.1 (SVN)
- Fixed in version: 2.1 (SVN)
- Fixed in revision: 63938 (#31487c5a)
- Target version: 2.2