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 :
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

  • edited October 2014
    PatF wrote: »
    If it can help, JEDI VCL return the following error :
    [00C8550E] frxPreview.TfrxPreviewWorkspace.MouseMove (Line 934, "frxPreview.pas" + 15) + $5E
    

    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
  • edited October 2014
    Paul Gursky has advised that the fix for this issue is to assign the custom preview object to the TfrxReport.Preview field before making the call to PrepareReport.

    Doing that seems to have fixed the problem for us in FR5.1.8
  • edited 2:21PM
    Thank you for the information.

    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.
  • edited 2:21PM
    PatF wrote: »
    Did they inform you if they would fix the bug?

    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 >
  • edited 2:21PM
    I found the solution... and it is so simple that I am disapointed the support couldn't reply. It seems they have removed the FPreview.Init from the TfrxReport.SetPreview between FastReport version 5.1.1 and 5.1.5. It is now necessary to call a TfrxReport.ShowPreparedReport before showing the form that contain the TfrxPreview.
    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;
      frxReport.ShowPreparedReport; // <----- THIS LINE IS NOW REQUIRED
      Form2.ShowModal;
      Form2.Free;
    
      frxReport.Free;
    end;
    
  • edited 2:21PM
    Or, as I indicated previously, you could just do this:
    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
    
      // Form2 only contain a TfrxPreview with the property "Align" set to "alClient"
      Form2 := TForm2.Create(Self);
      frxReport.Preview := Form2.frxPreview1;
    
      frxReport.PrepareReport(True);     // <-- Moved line
    
      Form2.ShowModal;
      Form2.Free;
    
      frxReport.Free;
    end;
    
  • edited 2:21PM
    However, as I indicated previously, it was not an option for me >
    revans wrote: »
    Or, as I indicated previously, you could just do this:
    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
    
      // Form2 only contain a TfrxPreview with the property "Align" set to "alClient"
      Form2 := TForm2.Create(Self);
      frxReport.Preview := Form2.frxPreview1;
    
      frxReport.PrepareReport(True);     // <-- Moved line
    
      Form2.ShowModal;
      Form2.Free;
    
      frxReport.Free;
    end;
    

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.