Click to See Complete Forum and Search --> : vb & c++ & COM & automation


R.D. Holland
October 22nd, 1998, 10:24 AM
Can I return the IUnknown pointer of a typelib's coclass or do I have to return the default interface pointer specified in my idl file? For example:


coclass MyCollection

{

[default] dispinterface IMyInterface;

interface IMyOtherInterface;

}


is a collection object I am exposing to vb automation clients from my c++ app. When accessed, I create my COM object and return its IUnknown.


But I am having problems with certain vb syntax when traversing the returned collection. If the vb code uses either the "for each object" or "MyCollection.Item(index)" syntax, everything is fine. But if I try to use "MyCollection(index)", vb calls the wrong function on MyCollection.


Neither my "Automation Programmer's Reference" book nor C++ documentation say what is expected to be passed from the server but from what I have read I am coming to the belief that I always have to return the default interface of any coclass in the typelib.

Felix Haas
October 22nd, 1998, 12:18 PM
You should post this topic in the Visual C++ board on codeguru.com, not in the Visual Basic board here...