Re: Interface Question
- From: "Maarten Wiltink" <maarten@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 9 Oct 2006 17:59:01 +0200
"Hans-Peter Diettrich" <DrDiettrich1@xxxxxxx> wrote in message
news:4ov58bFfu6gvU1@xxxxxxxxxxxxxxxxx
[...] If you want to cast an interface reference into an object
reference, simply implement an according interface method, which
does nothing but Result := Self;
The only time I ever got interfaces to work, I did just that.
Derived all interfaces not from IUnknown but from ImyUnknown
or something like that, which added a GetOwner method. ('Owner'
is _not_ the right term, by the way.)
It's not considered good style, however. Once you're doing things
through interfaces, you shouldn't go back to object references lest
you save one somewhere and it collapses under your feet because the
original interface reference went out of scope somewhere else and
the reference counting kicked in.
The approved way is to, once you have an interface reference to
an object, do _everything_ through interfaces from that point on.
This can be a very frustrating exercise if you're not set up for
it, because you end up needing interfacing corresponding to all
the classes you want to use it as (IPersistent, IComponent, IControl,
IForm, IButton, IEdit, IStrings, IStream, to give an idea).
Groetjes,
Maarten Wiltink
.
- Follow-Ups:
- Re: Interface Question
- From: Hans-Peter Diettrich
- Re: Interface Question
- References:
- Interface Question
- From: alanglloyd@xxxxxxx
- Re: Interface Question
- From: Maarten Wiltink
- Re: Interface Question
- From: Hans-Peter Diettrich
- Interface Question
- Prev by Date: Re: Interface Question
- Next by Date: Re: Interface Question
- Previous by thread: Re: Interface Question
- Next by thread: Re: Interface Question
- Index(es):