unit Unit3;
interface
type
TProg = procedure(S:String) of object;
TA = Class
Prog :Tprog;
procedure ABC;
end;
implementation
procedure TA.ABC;
begin
Prog('12345');
end
end.
//-----------------------------------------------------------------------
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm2= class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure Other(S:String);
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
procedure TForm2.Other(S:String);
begin
Form2.Canvas.TextOut(10,10,S);
Showmessage(S);;
end;
end.
//-------------------------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Unit2, Unit3, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
A :TA;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
A := TA.Create;
A.Prog := Form2.Other;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2.show;
A.ABC;
end;
end.