Search Results for

    Show / Hide Table of Contents

    Event Handler Description

    What should be done, if it is necessary to define a new event handler, which does not belong to the basic class? Let us examine it using the TfrxEditControl common control as an example:

      TfrxEditControl = class(TfrxDialogControl)
      private
        FEdit: TEdit;
        { new event }
        FOnChange: TfrxNotifyEvent;
        procedure DoOnChange(Sender: TObject);
        ...
      public
        constructor Create(AOwner: TComponent); override;
        ...
      published
        { new event }
        property OnChange: TfrxNotifyEvent read FOnChange write FOnChange;
        ...
      end;
    
    constructor TfrxEditControl.Create(AOwner: TComponent);
    begin
      ...
      { connect our handler }
      FEdit.OnChange := DoOnChange;
      InitControl(FEdit);
      ...
    end;
    
    procedure TfrxEditControl.DoOnChange(Sender: TObject);
    begin
      { call event handler }
      if Report <> nil then
        Report.DoNotifyEvent(Sender, FOnChange);
    end;
    

    It is important to notice that the event handler in FastReport is a procedure declared in report script. The string containing its name will be a link to the handler. That is why, for example, unlike the Delphi TNotifyEvent type, which is method address, handler type, in FastReport it is string (TfrxNotifyEvent type is declared as String[63]).

    Back to top © 1998-2022 Copyright Fast Reports Inc.