BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Storing a pointer to a TComInterface

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (ActiveX)
View previous topic :: View next topic  
Author Message
richard.rowell@gmail.com
Guest





PostPosted: Fri Mar 18, 2005 3:50 pm    Post subject: Storing a pointer to a TComInterface Reply with quote



I want to implement a TTreeView that will allow users to "browse"
objects in a COM component I'm using. I imported the type library, and
all works well, I'm just having problems getting RTTI stuff working. I
store a ptr to the interface pointer in the TTreeNode->Data property
like so:

ITablePtr cdh = tables->get_Item(i);
TTreeNode* cn = TreeView1->Items->AddChild(ntables,cdh->get__Name());
cn->Data = new ITablePtr(cdh);

But when I try to check the RTTI in the onExpanding event of the
TTreeNode, I run into problems...

void __fastcall TForm1::TreeView1Expanding(TObject *Sender,
TTreeNode *Node, bool &AllowExpansion)
{
ITablePtr* tptr;
void* data = Node->Data;
tptr = dynamic_cast< ITablePtr* >( data );
}

This will not compile, it dies on the dynamic cast line:
[C++ Error] Unit1.cpp(166): E2307 Type 'void' is not a defined class
with virtual functions

I'm guessing this has something to do with ITablePtr being a generated
interface:
typedef TComInterface<ITable, &DIID_ITable> ITablePtr;

Different nodes will store different types of objects, so I need the
RTTI to determine the type of the object. I guess I could just store
the IDispatch in a wrapper and re-construct the ITablePtr later on, but
I'm hoping to avoid that...

Thanks in advance!

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (ActiveX) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.