...
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComDog_TLB, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
protected
procedure Barked(Sender: TObject);
procedure Howled(Sender: TObject);
procedure Ate(Sender: TObject);
public
end;
var
Form1: TForm1;
TestDog: TDog;
iDog: _Dog;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
iDog := CoDog.Create;
TestDog := TDog.Create(self);
TestDog.ConnectTo(iDog);
TestDog.OnBark := Barked;
TestDog.OnHowl := Howled;
TestDog.OnEat := Ate;
end;
procedure TForm1.Barked(Sender: TObject);
begin
Memo1.Lines.Add('Event from
COM: Dog Barked');
end;
procedure TForm1.Howled(Sender: TObject);
begin
Memo1.Lines.Add('Event from
COM: Dog Howled');
end;
procedure TForm1.Ate(Sender: TObject);
begin
Memo1.Lines.Add('Event from
COM: Dog ate something');
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
if (TestDog <> nil) then
TestDog.Free;
end;
...