zoukankan      html  css  js  c++  java
  • [翻译]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 类型,它是一个方法的地址。

  • 相关阅读:
    编程谜题:提升你解决问题的训练场
    同态加密实现数据隐私计算,能让你的小秘密更加秘密
    interviewstreet pair
    x & (x 1)==0
    uva 11991 Easy Problem from Rujia Liu?
    hdoj 1230 火星A+B
    hdoj 1711 KMP Number Sequence
    HackerRank网站,为编码程序员们提供一个以编码谜题和现实生活中遇到的编码难题为基础的新兴的社交平台
    ACM博弈知识汇总
    hdoj 1202 水水更健康
  • 原文地址:https://www.cnblogs.com/moon25/p/5530823.html
Copyright © 2011-2022 走看看