例如TTimer控件,有一个OnTimer事件,
    property OnTimer: TNotifyEvent read FOnTimer write SetOnTimer;
    TNotifyEvent = procedure(Sender: TObject) of object;想通过Timer1:=TTimer.create;方式来创建,请问如何调用ONTimer事件,请给出例子,谢谢!

解决方案 »

  1.   

    事先定义好一个过程,然后让ONTimer事件指向该过程
      

  2.   

    如果是直接把控件放在FORM上,双击OnTimer即可,但现在是动态创建,不知如何触发该事件。
      

  3.   

    事先定义好一个过程,然后让ONTimer事件指向该过程能否给个例子?
      

  4.   

    定义过程: procedure myproc(Sender: TObject);指向:timer1.OnTimer := myproc;
      

  5.   

    定义过程: procedure myproc(Sender: TObject);
    指向:timer1.OnTimer := myproc;
    请问myproc中的代码为何不能执行?设断点却不进去。
      

  6.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls;type
      TForm1 = class(TForm)
           //procedure Timer1Timer(Sender: TObject);
        procedure T1(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.T1(Sender: TObject);
    begin
    form1.Caption:='test';
    end;procedure TForm1.FormCreate(Sender: TObject);
    var
    tt:ttimer;
    begin
    tt:=ttimer.Create(self);
    tt.OnTimer:=form1.T1;
    tt.Interval:=1000;
    end;end.