Dear Todd

My understanding is that interfaces inherit transparently (as you would
expect). QueryInterface should give you the answer you need.

A return result of 0 means success. An additional benefit is it does a
safe cast for you at the same time.

e.g. 

if NewObject.QueryInterface(IFirstDescendant, tmp) <> 0 then raise
exception.Create('Invalid FirstDecebdant object')
else 
begin
  tmp.foo;
end;

Stephen


> -----Original Message-----
> From: Todd Martin [mailto:[EMAIL PROTECTED] 
> Sent: Friday, 13 June 2003 1:53 p.m.
> To: Multiple recipients of list delphi
> Subject: [DUG]: Interface Inheritance
> 
> 
> Hi
> 
> Does anyone know if there's a way to test for interface 
> inheritance? For example
> 
> IFirstDescendant = interface(IInterface);
> ISecondDescendant = interface(IFirstDescendant);
> 
> TNewClass = class(TInterfacedObject,ISecondDescendant);
> 
> NewObject = TNewClass.Create;
> 
> is there a way to see whether NewObject supports the 
> interface "IFirstDescendant"
> 
> NewObject.GetInterface(IFirstDescendant,Descendant)
> returns a nil pointer for Descendant.
> 
> I'm thinking the VTable entry for the ISecondDescendant 
> interface, might link back to IFirstDescendant somehow.
> 
> Todd.
> 
> 
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List - 
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED] 
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
> 
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to