how to create an event onbeforeprint in runtime

procedure beforeprint(sender:tfrxcomponent);


masterdata.OnBeforePrint := 'beforeprint(nil)';


procedure trelatorio.beforeprint(sender:tfrxcomponent);
begin
showmessage('evento beforeprint executado'); // or some other thing
end;

=========

why it does not work, and why i need to set [OnBeforePrint := 'beforeprint(nil)';] like a String?
Its realy strange, and here i tryied to do it in many different ways, but always receive an error...

i just wanna set the OnBeforePrint in Runtime, and nothing more.

Can anyone help me?

Comments

  • gpigpi
    edited 7:03PM
    If you want to use OnBeforePrint event in Delphi's code - use TfrxReport.OnBeforePrint event
  • i have the same question...

    code:
    masterdata := tfrxmasterdata.create(frxreportpage);
      ............
      ...............
    
      masterdata.OnBeforePrint := my_before_print_event(nil);
    

    but... do not work [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> any idea?[/img]
  • gpigpi
    edited 7:03PM
    I have the same answer
    wrote:
    If you want to use OnBeforePrint event in Delphi's code - use TfrxReport.OnBeforePrint event
    You can assign TfrxMasterData.OnBeforePrint with script event only
  • gpi wrote: »
    I have the same answer
    gpi wrote: »
    If you want to use OnBeforePrint event in Delphi's code - use TfrxReport.OnBeforePrint event
    You can assign TfrxMasterData.OnBeforePrint with script event only

    thanks gpi,
    but dont work.
  • my code:



    unit classerelatorio;

    interface

    uses ....

    type

    trelatorio = class(tobject)

    procedure add_detail;
    ...
    ...
    ...
    private
    procedure masterdata1onbeforeprint(sender: tfrxcomponent);
    public
    end;
    ...
    var
    relatorio : trelatorio;

    implementation

    uses

    ...

    procedure trelatorio.add_detail;
    var
    masterdata : tfrxmasterdata;
    begin
    masterdata := tfrxmasterdata.create(frxreportpage);
    masterdata.name := 'masterdata1';
    masterdata.dataset := dataset;
    masterdata.onbeforeprint := 'masterdata1onbeforeprint'; // its correct ???
    end;

    procedure masterdata1onbeforeprint(sender:tfrxcomponent);
    begin
    // code....
    end;




  • gpigpi
    edited 7:03PM
    wrote:
    masterdata.onbeforeprint := 'masterdata1onbeforeprint'; // its correct ???
    Yes, but masterdata1onbeforeprint event should be placed in script code, not in Delphi code
  • Thanks GPI

    in the tfsscript ?

    any example ?
  • edited 7:03PM
    When you say script, did you mean this?
    FR.png 45.4K
  • gordkgordk St.Catherines On. Canada.
    edited 7:03PM
    When building reports from delphi code you can create events for the internal report script and connect them to objects.
    here is a sample.
  • thanks gordk...
    Very pleased with your help.
  • gpi wrote: »
    gpi wrote: »
    masterdata.onbeforeprint := 'masterdata1onbeforeprint'; // its correct ???
    Yes, but masterdata1onbeforeprint event should be placed in script code, not in Delphi code

    thank you gpi
  • gordk wrote: »
    When building reports from delphi code you can create events for the internal report script and connect them to objects.
    here is a sample.


    its running [img]style_emoticons/<#EMO_DIR#>/cool.gif" style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif" /> thanks gordk, gpi and galdariah[/img]
  • keturpatelketurpatel India
    edited May 2012
    gordk wrote: »
    When building reports from delphi code you can create events for the internal report script and connect them to objects.
    here is a sample.

    I'm trying to add event to memoview at runtime, but cannot find way to assign event.

    I'm using VB6 and creating report at runtime with several memoviews.
    I have added script to report object, which has some variables and procedures.

    Now i want to assign one of script procedure to obp event of memoview.
    but cant find way to do so. my fastreport version is 4.9

    Please help me.
    Thanks in advance.

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.