2012-01-16 13 views
11

Documentation afferma che la delega dell'interfaccia è disponibile solo per Win32. Attualmente non riesco a testarlo, è un bug di documentazione o la delega dell'interfaccia è stata interrotta nel compilatore a 64 bit?Delega di interfaccia su Win64

risposta

9

Si tratta di un bug di documentazione. I seguenti segnali acustici in Win64:

program Win64delegatedInterfaces; 

{$APPTYPE CONSOLE} 

uses 
    SysUtils; 

type 
    IIntf = interface 
    procedure Foo; 
    end; 

    TMyClass = class(TObject, IIntf) 
    FIntf: IIntf; 
    property Intf: IIntf read FIntf implements IIntf; 
    end; 

    TMyOtherClass = class(TInterfacedObject, IIntf) 
    procedure Foo; 
    end; 

var 
    MyClass: TMyClass; 
    Intf: IIntf; 

procedure TMyOtherClass.Foo; 
begin 
    Beep; 
end; 

begin 
    MyClass := TMyClass.Create; 
    MyClass.FIntf := TMyOtherClass.Create; 
    Intf := MyClass; 
    Intf.Foo; 
end.