• [翻译]Event Handler Description 事件处理描述


    Event Handler Description 事件处理描述 (自定义控件)

    How should a new event handler be defined if it does not already belong to the base class? Let's look at this using the “TfrxEditControl” common control as an example:

    一个新的事件处理程序应该如何定义,如果它不属于基类?让我们看看使用“TfrxEditControl“控件为例:

    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;   //在Create中关联事件(把TEdit控件的事件关联到自己的过程中)

    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 note that the event handler in FastReport is a procedure defined in the report script. The TfrxNotifyEvent type is declared as String[63] and in FastReport the link to the handler is a string containing its name. This is unlike the Delphi TNotifyEvent type, in which it is a method address.

    很重要的提示,事件处理程序是在报表脚本中定义的过程。TfrxNotifyEvent 类型被声明为String[63],并且在FastReport链接的事件处理过程是一个字符串(包含它的名字)。这个不像Delphi中的TNotifyEvent 类型,它是一个方法的地址。

  • 相关阅读:
    Red Hat Enterprise Linux 4 下安装 Oracle 10g [转]
    C# 轻松实现对窗体(Form)换肤[转]
    广州.NET俱乐部第一次活动安排暨动员书
    庆祝广州.net俱乐部成立暨迎接新成员暨讨论社区活动
    有感于广州.NET俱乐部的成立暨全体动员书
    如何在列表模板中增加一个计算列
    BI有感续
    BI有感
    列表属性查看器WebPart
    广州.NET第一次活动内容及演讲安排(本贴持续更新中)
  • 原文地址:https://www.cnblogs.com/moon25/p/5530823.html
Copyright © 2020-2023  润新知