Nahum
If your object is a TComponent then use
if TComponent(fMyList[i]).QueryInterface(ICommandInterface,IntVar) then
IntVar.Prune
I've had problems with the Supports function when casting inside procedures
HTH
Neven
----- Original Message -----
From: Nahum Wild <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Sent: Thursday, 2 November 2000 09:44
Subject: [DUG]: Today's Mental block
> I'm trying to determine if an object implements an interface, and I'm
having
> a complete mental block about it.
>
> The situation is that I have a TList of objects that ALL implement
IUnknown.
> Some in the list might implement ICommandCluster and I want to test for
this
> and do something with them if they do. I'm pretty sure I've done
something
> in the past that was nice and simple/elegant to determine if an object
> implemented a particular interface, but as I said I'm having a complete
> mental block about it.
>
> Currently I'm just forcibly casting at runtime the objects to the
interface
> and trapping the exception generated if it don't work.
>
> for i := fUndoList.Count-1 do begin
> try
> (fMyList[i] as ICommandInterface).Prune;
> except
> on E: EIntfCastError do begin
> // do nothing
> end;
> end;
> end;
>
> This is pretty yuck and want to do it a better/nicer way. Does anybody
know
> what I'm taking about and/or can help??
>
>
> Cheers,
>
> Nahum Wild
> Game Designer
> Realism Ltd
>
>
> Pre-Register now for the ESDAO beta test!
> http://www.esdao.net
>
> Also the official home of the FatFree Browser
>
> --------------------------------------------------------------------------
-
> 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"
>
---------------------------------------------------------------------------
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"