?
Solved

How to add an Interface type to a container

Posted on 2003-03-03
6
Medium Priority
?
215 Views
Last Modified: 2012-05-04
Hello All,

Can anybody tell me how I could add an Object (which has been typecasted to an Interface) in any of Delphi Containers.

The reason I have typecasted to an Interface is, mainly due to multiple inheritance.

I tried to add the object to a TList and to a TObjectList with no success. It says "Incompatible types"

It looks like TList or TObjectList don't like to add anything which has been typecasted to an interface.


Thanks in advance,
Jeewa
0
Comment
Question by:Wallstreet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 21

Accepted Solution

by:
ziolko earned 150 total points
ID: 8060442
dont do typecast and use TInterfaceList.
ziolko.
0
 
LVL 2

Expert Comment

by:BorlandMan
ID: 8061800

yep.

also, keep in mind that when you add that interface to TInterfacelist that the Interface will not drop out of memory until you delete it from the TInterfaceList.... which is pretty much what you want (right?)

J
0
 

Author Comment

by:Wallstreet
ID: 8064366
Thank you verymuch Ziolko
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Wallstreet
ID: 8064378
Thank for the insights BorlandMan
0
 
LVL 21

Expert Comment

by:ziolko
ID: 8065231
WallStreat one more tip if You will try to typecast Interface to pointer You have to call _AddRef after typecast and _Release before destroying interface.
ziolko.
0
 

Author Comment

by:Wallstreet
ID: 8066791
Ziolko,

I don't have an immediate need to do that but appreciate you telling me.

Thank You.
Wallstreet
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question