Start New Discussion within our Software Development Community

I am doing an ATL Project in VC++ 2005 to use as ActiveX in VB6. I added methods, properties and events following the steps in this tutorial: Everything is working fine while I'm working inside the class. But now I need to call an event or method of the class but from a global method.

I already tried to query an interface, but the event is not dispatched; maybe I'm not doing it well.

How can I do this?


The problem is just the came as in any other c++ program -- the global method must have an instance of the c++ class in order to call one of its methods, unless the c++ class method has been declared as static.

class foo
   static int static_method() { return 0; }
   int another_method();

void gmethod()
   foo par;
   foo::static_method(); // call a static method

   par.another_method(); // call a non-static method

Thanks for your reply.

But the methods are not static and when I try:

CEngine engine;

...I get the following errors:

.\Engine.cpp(966) : error C2259: 'CEngine' : cannot instantiate abstract class 
        due to following members:
        'HRESULT CEngine::QueryInterface(const IID &,void **) throw()' : is abstract
        d:\projects\visualstudio\2005\facerecognition\facerecognition\Engine.h(91) : see declaration of 'CEngine::QueryInterface'

I also tried:

CEngine engine;
hr = CoCreateInstance(CLSID_Engine, NULL, CLSCTX_INPROC_SERVER, IID_IEngine, (void **) & engine);
if(SUCCEEDED(hr)) {



This compiles just fine, but when I run the client application, it gives me an exception. I also tried with IID_IDispatch and IID_ConnectionPointContainer, but no luck.

Do you have other hint?

This article has been dead for over six months. Start a new discussion instead.