 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Alex Guest
|
Posted: Wed Sep 01, 2004 7:01 pm Post subject: Returning an interface through an activex object |
|
|
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
|
Posted: Wed Sep 01, 2004 7:36 pm Post subject: Re: Returning an interface through an activex object |
|
|
"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
|
Posted: Thu Sep 02, 2004 5:49 pm Post subject: Re: Returning an interface through an activex object |
|
|
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 |
|
 |
|
|
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
|
|