i have some probelm with use procedural from one object interface :
unit Unit2;
interface
uses
Windows, Messages, SysUtils,Classes, Controls, Forms,Dialogs;
type
TDoProcedure = procedure(const FldName : string) of object;
IOneInterface = interface(IInterface) //universal way for any Direct DB
Worker
['{4BFEE200-1665-4F23-B430-D0076CD164EA}']
procedure DoIt(const FldName : string);
end;
TClassI = class(TInterfacedObject,IOneInterface)
public
procedure DoIt(const FldName : string);
constructor Create;
end;
TOtherClass = class(TObject)
public
constructor Create(DoJob : TDoProcedure);
end;
TForm2 = class(TForm)
procedure FormCreate(Sender: TObject);
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
constructor TClassI.Create;
begin
inherited;
end;
procedure TClassI.DoIt(const FldName : string);
begin
ShowMessage(FldName);
end;
constructor TOtherClass.Create(DoJob : TDoProcedure);
begin
DoJob('test');
end;
procedure TForm2.FormCreate(Sender: TObject);
var
IClass : IOneInterface;
AotherClass : TOtherClass ;
begin
IClass := TClassI.Create as IOneInterface;
AotherClass := TOtherClass.Create(IClass.DoIt);
//<--- ERROR [Error] Unit2.pas(64): Not enough actual parameters
end;
end.
what is problem in line: AotherClass := TOtherClass.Create(IClass.DoIt);
what is my problem ?
how Resolve it ?
if can not do it how callback when using interface ?
Thx
unit Unit2;
interface
uses
Windows, Messages, SysUtils,Classes, Controls, Forms,Dialogs;
type
TDoProcedure = procedure(const FldName : string) of object;
IOneInterface = interface(IInterface) //universal way for any Direct DB
Worker
['{4BFEE200-1665-4F23-B430-D0076CD164EA}']
procedure DoIt(const FldName : string);
end;
TClassI = class(TInterfacedObject,IOneInterface)
public
procedure DoIt(const FldName : string);
constructor Create;
end;
TOtherClass = class(TObject)
public
constructor Create(DoJob : TDoProcedure);
end;
TForm2 = class(TForm)
procedure FormCreate(Sender: TObject);
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
constructor TClassI.Create;
begin
inherited;
end;
procedure TClassI.DoIt(const FldName : string);
begin
ShowMessage(FldName);
end;
constructor TOtherClass.Create(DoJob : TDoProcedure);
begin
DoJob('test');
end;
procedure TForm2.FormCreate(Sender: TObject);
var
IClass : IOneInterface;
AotherClass : TOtherClass ;
begin
IClass := TClassI.Create as IOneInterface;
AotherClass := TOtherClass.Create(IClass.DoIt);
//<--- ERROR [Error] Unit2.pas(64): Not enough actual parameters
end;
end.
what is problem in line: AotherClass := TOtherClass.Create(IClass.DoIt);
what is my problem ?
how Resolve it ?
if can not do it how callback when using interface ?
Thx