How to assign Delphi OnBeforePrint event handler?

edited October 2016 in FastReport VCL 5
Hi all!

I want to assign an OnBeforePrint handler implemented in Delphi to a TfrxPictureView at runtime, something like
  procedure InitPicture(const AName: string);
  var
    c: TComponent;
    pict: TfrxPictureView;
  begin
    c := fastReport1.FindComponent(AName);
    if Assigned(c) and (c is TfrxPictureView) then
    begin
      pict := TfrxPictureView(c);
      pict.OnBeforePrint := Picture2BeforePrint;
    end;
  end;
with a method
  TMyClass = class(...)
    ...
    procedure Picture2BeforePrint(Sender: TfrxComponent);
    ...
  end;
but of course this doesn't work because <!--fonto:Courier New--><span style="font-family:Courier New"><!--/fonto-->TfrxReportComponent.OnBeforePrint<!--fontc--></span><!--/fontc--> is in fact a string property, not an event property.

How can I achieve my goal?

Comments

  • gpigpi
    edited 6:38PM
    You may assign TfrxPictureView.OnBeforePrint with script procedure only
    Use TfrxReport.OnBeforePrint event for Delphi's code
  • edited 6:38PM
    gpi wrote: »
    You may assign TfrxPictureView.OnBeforePrint with script procedure only
    Use TfrxReport.OnBeforePrint event for Delphi's code
    Thanks for your answer, gpi!

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.