Events in Delphi

Hello,

I start programming with FastReport and I have a question about the events.

What is the best way to use the report's events in Delphi? For exemple, how can I launch code in delphi when the BeforePrint event of the report occurs.

I want to translate my old QuickReport reports to FastReport. I used the OnStartPage et OnEndPage events. How can I translate these events?

Thank you for your answer.

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 7:54PM
    Hello,

    I start programming with FastReport and I have a question about the events.

    What is the best way to use the report's events in Delphi? For exemple, how can I launch code in delphi when the BeforePrint event of the report occurs.
    gk the best way is what suits your needs, nothing particular.
    the onbefore print event of the tfrxreport component fires for every object in the reportdesign, each time it is encountered.
    typical sample code
    procedure TForm1.frxReport1BeforePrint(Sender: TfrxReportComponent);
    var
    idx2: integer;
    mymemo2: tfrxmemoview;
    begin
    // does not fire for page so start with titleband
    if sender.name = 'ReportTitle1' then
    begin
    mymemo2 := frxreport1.findobject('Memo3')as tfrxmemoview;\\ use find object method
    idx2 := frxreport1.Script.Variables;
    mymemo2.memo.add(inttostr(idx2)+' **** external obp event fired for titleband');
    mymemo2.memo.add(' NOTE the obp event handler of the tfrxreport component fires for every object in the report');
    mymemo2.memo.add(' did not write code in the event for every object just note external fires before internal');
    inc(idx2);
    frxreport1.Script.Variables:= idx2;
    end;
    if sender.name = 'PageHeader1' then
    begin
    mymemo2 := frxreport1.findobject('Memo3')as tfrxmemoview;
    idx2 := frxreport1.Script.Variables;
    mymemo2.memo.add(inttostr(idx2)+' **** external obp event fired for page header band');
    inc(idx2);
    frxreport1.Script.Variables:= idx2;
    end;
    end;


    I want to translate my old QuickReport reports to FastReport. I used the OnStartPage et OnEndPage events. How can I translate these events?
    Thank you for your answer.
    gk
    onstart usually translates to onbeforeprint onend usually translates to onafterprint.
    it may have a different context if the report is a multidesignpage report.
    the code above is a sampl bit from a demo for newbies in the frbinaries news group

    You can also use the find object method to find an object and modify its properties
    after a report design is loaded and before showreport or prepare report is called.

  • edited 7:54PM
    OK but that's mean that I must have a page header and a page footer band. If I want to write a generic code, I must verify if these two bands exist and create them if not after loading the report.
    If my page header and my page footer band have its height equal 0, is the before print event works?

    Best regards
  • gordkgordk St.Catherines On. Canada.
    edited 7:54PM
    if a band has a 0 height the events still fire, in some very complex reports, this can be utilized
    to have events available for use (ie seed variable values etc).

    you dont have to have a page header and a page footer.

    A band is just a place holder on the design page, the bands are processed from top down according to their type, basicly they control the report engine's output to the finished page, the band is not output only the objects it contains.

    Be very careful when altering design heights of bands from delphi if you make the height to small
    you can widow objects to the page.
    read the programmers manual mostly as working from delphi
    and the users manual mainly as working inside the report.





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.