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 

Returning an interface through an activex object

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





PostPosted: Wed Sep 01, 2004 7:01 pm    Post subject: Returning an interface through an activex object Reply with quote



I have created an interface, that returns a data structure instead of
scalar values.
Since one cannot return user defined structures through an ActiveX
interface, I created a second interface, that takes the data.
Then, in the method that should return the interface, I created an
instance via the IDispatch interface. It looks something like this:

In the class declaration:
....
private:
IMyOleComponentDisp Server;
....

in my method
....
Server.BindDefault();
Server.MyfunctionThatPassesDataToServer(MyData);

Now I have a working Dispatch interface, but how can I pass it as a return
value to the function? The function can only have a parameter of type
IMyOleComponent**, so I cannot return the dispatch interface directly.

What's the solution to this, or am I doing it completely wrong.

Thanks,
Alex
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Sep 01, 2004 7:36 pm    Post subject: Re: Returning an interface through an activex object Reply with quote




"Alex" <mycroft_5 (AT) hotmail (DOT) com> wrote


Quote:
Now I have a working Dispatch interface, but how can I pass it
as a return value to the function? The function can only have a
parameter of type IMyOleComponent**, so I cannot return the
dispatch interface directly.

Yes, you can. That is exactly what such methods do. For example:

HRESULT __stdcall TMyActiveXImpl::GetTheInterface(IMyData** Result)
{
IMyData *pInst = NULL;
// instantiate pInst as needed...
*Result = pInst;
pInst->AddRef();
return S_OK;
}

Then you call it like this:

IMyActiveX* pInst = NULL;
// instantiate pInst as needed...

IMyData* pData = NULL;
pInst->GetTheInterface(&pData);
// use pData as needed...
pData->Release();
//...
pInst->Release();


Gambit



Back to top
Alex
Guest





PostPosted: Thu Sep 02, 2004 5:49 pm    Post subject: Re: Returning an interface through an activex object Reply with quote



On Wed, 01 Sep 2004 12:36:28 -0700, Remy Lebeau (TeamB) wrote:


Quote:
Yes, you can. That is exactly what such methods do. For example:
[...]


Now it works. Thank you!

regards,
Alex

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.