<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content=text/html;charset=ISO-8859-1>
<META content="MSHTML 6.00.2900.2873" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi Phil</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Yes, I agree TOleCoordinateList should be
referenced by interface IOleCoordinateList and TOleCoordinate should be
referenced by interface IOleCoodinate, but I was refering to the
internal TLIST that Andrew mentioned, which holds the automation objects
inside TOleCoordinateList. As Conor pointed out, that should be TInterfaceList.
You would only be forced to reference this internal list by interface, if you
were exposing it as a public property of TOleCoordinateList, which would be bad
practice anyway IMHO.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Todd.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=phil@tumonz.co.nz href="mailto:phil@tumonz.co.nz">Phil Middlemiss</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=delphi@ns3.123.co.nz
href="mailto:delphi@ns3.123.co.nz">NZ Borland Developers Group - Delphi
List</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, June 13, 2006 12:03
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [DUG] (no subject)</DIV>
<DIV><BR></DIV>True. You could get away with just using a TInterfaceList
object. But you would have to be extremely careful to *never* cause it's
RefCount to increment/decrement. Which, when you're talking about automation
objects seems unlikely if that TAOleCoordinateList is made visible through the
automation interfaces. Personally, I find it much easier to just use an
IInterfaceList holder - then I never need worry about it. Which is kinda how
it's designed after all.....<BR><BR>I know Andrew (not Thomas as I referred to
you earlier Andrew - your email shows your last name first) wanted to add a
TAOleCoordinate to his list, but I was implying that he should really use an
interface from when it is created anyway. To me, trying to handle automation
objects as objects and not interfaces just adds a level of complexity that I
can do without since automation objects are inevitably going to have their
reference count incremented/decremented by the automation client. But I guess
if you can safely guarantee that reference counting will never be an issue
then go ahead and just use a TInterfaceList.<BR><BR>Phil.<BR><BR>Todd Martin
wrote:
<BLOCKQUOTE cite=mid00ab01c68e79$2acf3f10$896f96ca@p2400 type="cite">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR>
<STYLE></STYLE>
<DIV><FONT face=Arial size=2>Ah. I'm sorry I disagree.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Firstly, Andrew wanted to add a TAOleCoordinate
to his TAOleCoordinateList. So the Add() method expected a
TAOleCoordinate parameter, NOT a TAOleCoordinateList
parameter.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Secondly, there is no need to always
reference TInterfaceList with an interface.</FONT></DIV>
<DIV><FONT face=Arial size=2>So the declaration</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>TMyClass=class(TObject)</FONT></DIV>
<DIV><FONT face=Arial size=2>private</FONT></DIV>
<DIV><FONT face=Arial size=2> FInterfaceList :
TInterfaceList;</FONT></DIV>
<DIV><FONT face=Arial size=2>end;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>is fine, provided you NEVER extract an
interface reference to the list object. The reference count in
FInterfaceList starts at zero, when it is created, and remains at zero, and
is destroyed with FInterfaceList.Free().</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Conor, </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>the reason you need to use _AddRef on your
TInterfaceList, is that somewhere in your code you are refering to the
internal list with something like this</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>procedure SomeMethod()</FONT></DIV>
<DIV><FONT face=Arial size=2>var</FONT></DIV>
<DIV><FONT face=Arial size=2> LocalList : IInterfaceList; //interface
variable</FONT></DIV>
<DIV><FONT face=Arial size=2>begin</FONT></DIV>
<DIV><FONT face=Arial size=2> MyObject :=
TMyClass.Create();</FONT></DIV>
<DIV><FONT face=Arial size=2> LocalList :=
MyObject.FInterfaceList;</FONT></DIV>
<DIV><FONT face=Arial size=2>//
LocalList.Add(AInterface);</FONT></DIV>
<DIV><FONT face=Arial size=2>....</FONT></DIV>
<DIV><FONT face=Arial size=2>end;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>this extracts an interface reference to
FInterfaceList and increases the reference count to 1. As soon as LocalList
goes out of scope, ie at the end of SomeMethod(), the reference count drops
back to zero and FInterfaceList is destroyed!</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Personally, to enforce encapsulation, I think
FInterface should never be accessed directly. You should add methods to your
containing object instead. Like so</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2>TMyClass=class(TObject)</FONT></DIV>
<DIV><FONT face=Arial size=2>private</FONT></DIV>
<DIV><FONT face=Arial size=2> FInterfaceList :
TInterfaceList;</FONT></DIV>
<DIV>public</DIV>
<DIV> function Add(AInterface : IInterface) : Integer;</DIV>
<DIV> function Remove(AInterface : IInterface) : Integer;</DIV>
<DIV><FONT face=Arial size=2>end;</FONT></DIV></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Which is what Andrew is doing.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Todd.</FONT></DIV>
<DIV> </DIV>
<DIV>----- Original Message ----- </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV
style="BACKGROUND: rgb(228,228,228) 0% 50%; FONT: 10pt arial; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial; font-size-adjust: none; font-stretch: normal"><B>From:</B>
<A title=phil@tumonz.co.nz href="mailto:phil@tumonz.co.nz">Phil
Middlemiss</A> </DIV>
<DIV
style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><B>To:</B>
<A title=delphi@ns3.123.co.nz href="mailto:delphi@ns3.123.co.nz">NZ
Borland Developers Group - Delphi List</A> </DIV>
<DIV
style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><B>Sent:</B>
Tuesday, June 13, 2006 9:42 AM</DIV>
<DIV
style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><B>Subject:</B>
Re: [DUG] (no subject)</DIV>
<DIV><BR></DIV>TInterfaceList is descended from TInterfacedObject, so it
needs to be referenced with an interface to keeps it's reference count
above 0 - else it will be destroyed along with all the objects it
contains.<BR><BR>eg,<BR><BR>TMyObject =
class(TObject)<BR>private<BR> FInterfaceList :
IInterfaceList;<BR>public<BR> constructor
create;<BR>end;<BR><BR>constructor TMyObject.create;<BR>begin<BR>
FInterfaceList := TInterfaceList; // automatic typecast to
IInterfaceList<BR>end;<BR><BR>Conor Boyd wrote:
<BLOCKQUOTE
cite=mid8285CB7241FCFC4BB721A6F953F9B35E04A66206@nzc-ap-xch-01.ap.trimblecorp.net
type="cite">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR>
<DIV dir=ltr align=left><SPAN class=117441421-12062006><FONT face=Arial
color=#0000ff size=2>Can you clarify that for me?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN
class=117441421-12062006></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=117441421-12062006><FONT face=Arial
color=#0000ff size=2>Why does it *need* to be referenced with an
IInterfaceList?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN
class=117441421-12062006></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=117441421-12062006><FONT face=Arial
color=#0000ff size=2>I've just started using a TInterfaceList to
hold references to interfaces, but I don't see why I have to use
interfaces WRT the list itself?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN
class=117441421-12062006></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=117441421-12062006><FONT face=Arial
color=#0000ff size=2>Having said that, I have an issue where I have to
explicitly call _AddRef on the interface I'm adding to my interfacelist
to keep it alive. Could these two things be
related?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN
class=117441421-12062006></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=117441421-12062006><FONT face=Arial
color=#0000ff size=2>Grateful for your thoughts...</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN
class=117441421-12062006></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=117441421-12062006><FONT face=Arial
color=#0000ff size=2>C.</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
</DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma><FONT size=2><B>From:</B> <A class=moz-txt-link-abbreviated
href="mailto:delphi-bounces@ns3.123.co.nz">delphi-bounces@ns3.123.co.nz</A>
[<A class=moz-txt-link-freetext
href="mailto:delphi-bounces@ns3.123.co.nz">mailto:delphi-bounces@ns3.123.co.nz</A>]
<B>On Behalf Of </B>Phil Middlemiss<BR><SPAN
class=117441421-12062006><FONT face=Arial
color=#0000ff> </FONT></SPAN></FONT></FONT></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>No, it
wasn't a typo - he needs to *create* a TInterfaceList - but that list
needs to be *referenced* with an IInterfaceList. It was intentional to
force Thomas to look up how to end up with a working
IInterfaceList.<BR><BR>Conor Boyd wrote: </DIV>
<BLOCKQUOTE
cite=mid8285CB7241FCFC4BB721A6F953F9B35E04A661A3@nzc-ap-xch-01.ap.trimblecorp.net
type="cite">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR>
<DIV dir=ltr align=left><SPAN class=552015620-12062006><FONT
face=Arial color=#0000ff size=2>I'm sure it was just a typo, but it
should be a TInterfaceList instead of a TList.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN
class=552015620-12062006></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=552015620-12062006><FONT
face=Arial color=#0000ff size=2>Cheers,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN
class=552015620-12062006></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=552015620-12062006><FONT
face=Arial color=#0000ff size=2>Conor</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
</DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma><FONT size=2><B>From:</B> <A
class=moz-txt-link-abbreviated
href="mailto:delphi-bounces@ns3.123.co.nz">delphi-bounces@ns3.123.co.nz</A>
[<A class=moz-txt-link-freetext
href="mailto:delphi-bounces@ns3.123.co.nz">mailto:delphi-bounces@ns3.123.co.nz</A>]
<B>On Behalf Of </B>Phil Middlemiss<BR><SPAN
class=552015620-12062006><FONT face=Arial
color=#0000ff> </FONT></SPAN></FONT></FONT></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma><FONT size=2><SPAN
class=552015620-12062006></SPAN></FONT></FONT><FONT face=Tahoma><FONT
size=2><SPAN class=552015620-12062006><FONT face=Arial
size=2>[snip]</FONT> </SPAN></FONT></FONT></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><SPAN
class=552015620-12062006></SPAN> </DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>You
should also be adding it to an IInterfaceList instead of a
TList.<BR><BR>
<P><FONT face=Arial size=2>[snip]</FONT> </P></DIV></BLOCKQUOTE><PRE wrap=""><HR width="90%" SIZE=4>
_______________________________________________
Delphi mailing list
<A class=moz-txt-link-abbreviated href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</A>
<A class=moz-txt-link-freetext href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</A>
</PRE></BLOCKQUOTE>
<P></P>
<HR>
_______________________________________________<BR>Delphi mailing
list<BR><A class=moz-txt-link-abbreviated
href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</A><BR><A
class=moz-txt-link-freetext
href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</A><BR>
<P></P>
<HR>
No virus found in this incoming message.<BR>Checked by AVG Free
Edition.<BR>Version: 7.1.394 / Virus Database: 268.8.3/361 - Release Date:
11/06/2006<BR></BLOCKQUOTE><PRE wrap=""><HR width="90%" SIZE=4>
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.8.3/361 - Release Date: 11/06/2006
</PRE><PRE wrap=""><HR width="90%" SIZE=4>
_______________________________________________
Delphi mailing list
<A class=moz-txt-link-abbreviated href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</A>
<A class=moz-txt-link-freetext href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</A>
</PRE></BLOCKQUOTE>
<P>
<HR>
<P></P>_______________________________________________<BR>Delphi mailing
list<BR>Delphi@ns3.123.co.nz<BR>http://ns3.123.co.nz/mailman/listinfo/delphi<BR>
<P>
<HR>
<P></P>No virus found in this incoming message.<BR>Checked by AVG Free
Edition.<BR>Version: 7.1.394 / Virus Database: 268.8.3/361 - Release Date:
11/06/2006<BR></BLOCKQUOTE></BODY></HTML>