Problem with TfrxPreview
Hi,
I know version 5.1.7 is a beta version, but there is a bug that prevent me from using that version.
My software prepare the report in the main form and later show it in a TfrxPreview contained in another form. This is a simple version of the code :
If it can help, JEDI VCL return the following error :
I know version 5.1.7 is a beta version, but there is a bug that prevent me from using that version.
My software prepare the report in the main form and later show it in a TfrxPreview contained in another form. This is a simple version of the code :
procedure TForm1.Button1Click(Sender: TObject);
var
  frxReport: TfrxReport;
begin
  frxReport := TfrxReport.Create(nil);
  frxReport.LoadFromFile('test.fr3'); // Report with no bands and only a TfrxMemoView
  frxReport.PrepareReport(True);
  // Form2 only contain a TfrxPreview with the property "Align" set to "alClient"
  Form2 := TForm2.Create(Self);
  frxReport.Preview := Form2.frxPreview1;
  Form2.ShowModal;
  Form2.Free;
  frxReport.Free;
end;
The code above is working without any problem while using Delphi 2010 and FastReport VCL version 5.1.1, but it gives many access violation when moving the mouse over the TfrxPreview using the version 5.1.7.If it can help, JEDI VCL return the following error :
[00C8550E] frxPreview.TfrxPreviewWorkspace.MouseMove (Line 934, "frxPreview.pas" + 15) + $5E
Comments
I can confirm that I am seeing exactly the same problem on line 934 of frxPreview.pas in FR5.1.7 - the problem is that the PreviewPages object is nil at that point, so the call to PreviewPages.ObjectOver fails with an AV.
The application code that requests the custom preview is known to work correctly in FR4. [And we have seen no documentation to suggest that Custom Preview in FR5 needs to be initialised or called in a different way.]
So it looks like the code that should initialise the pointer to PreviewPages is missing from FR5.1.7
Doing that seems to have fixed the problem for us in FR5.1.8
Did they inform you if they would fix the bug?
During the last year, I developped printing routines that use this specific feature (preparing a report and allowing the user to send it to different destinations after it has been generated). It would be possible for me to spend many hours to change my code, but it seems silly since it used to work in the last stable version (5.1.1).
I don't need an immediate fix, but I need this bug to be fixed before updating my version of the sources.
I did not press them on the point but received the impression that they do not regard this new behaviour as a bug.
But I did suggest that they might like to include mention of this (currently undocumented) requirement for TfrxPreview in the FR5 VCL Programmer's Manual when it is eventually released.
In the case of my own code, the necessary change was quite small as I already know before preparing the report whether or not I will need to show a custom preview.
However (I haven't tested this but) I would guess that there is no real reason why a custom preview object shoulnd not be assigned to the report (unconditionally) prior to preparing - just don't show the preview if it isn't needed