Returning a dispinterface from VC to VB
-
I'm trying to write a function which returns a pointer to itself from my ATL C++ code to a VB application. My ATL object uses dispinterfaces to be compatible with VB. In my IDL, I declare the my function: [id(1)] HRESULT GetComponent ([out, retval] IDispatch *pRetval); I implement the function OK and return a pointer to IDispatch that I've obtained with QueryInterface. Oh, this interface is part of a coclass alled "MyControl". So GetComponent basically returns QueryInterface on "this". (And it works, too:)) I declare the interface as "oleautomation". Now using the Visual Basic object browser, I can see my GetComponent method and it's returning an "object". Now, I can set it OK if I set it as an object: Dim Test as Object Set Test = oControl.GetComponent ' oControl is type MyControl However, if I declare "Test" as type "MyControl", I get a type mismatch: Dim Test as MyControl set Test = oControl.GetComponent ' Causes a type mismatch Help! I just cannot get this to work. Is there something i must mark the IDL with, or is this a Visual Basic issue?:mad: Thanks in advance :) Jon
-
I'm trying to write a function which returns a pointer to itself from my ATL C++ code to a VB application. My ATL object uses dispinterfaces to be compatible with VB. In my IDL, I declare the my function: [id(1)] HRESULT GetComponent ([out, retval] IDispatch *pRetval); I implement the function OK and return a pointer to IDispatch that I've obtained with QueryInterface. Oh, this interface is part of a coclass alled "MyControl". So GetComponent basically returns QueryInterface on "this". (And it works, too:)) I declare the interface as "oleautomation". Now using the Visual Basic object browser, I can see my GetComponent method and it's returning an "object". Now, I can set it OK if I set it as an object: Dim Test as Object Set Test = oControl.GetComponent ' oControl is type MyControl However, if I declare "Test" as type "MyControl", I get a type mismatch: Dim Test as MyControl set Test = oControl.GetComponent ' Causes a type mismatch Help! I just cannot get this to work. Is there something i must mark the IDL with, or is this a Visual Basic issue?:mad: Thanks in advance :) Jon