__hook - C2039 - is not a member of

M

Masterchief

HY!

I have a problem hooking an event. I get an compiler error, that my callback
isn´t a memeber of the containing class. I canßt find anything I am doing
wrong.
I found a small coed example which reproduces the compiler error.

[object, uuid("99BE5DDB-0661-496E-BA84-8DE522E817C9"), dual, oleautomation]
__interface ITest
{



};


[dispinterface, uuid("C3D67614-608A-44D1-BA7D-9586A21C14F4")]
__interface ITestEvents
{
[id(1)]
HRESULT TestEvent([in] ITest *pITest);


};


[coclass, uuid("D3EDEB8D-0756-4705-B167-3939DD480DF3"), event_source(com),
event_receiver(com)]
class ATL_NO_VTABLE Test : public ITest
{
BEGIN_COM_MAP(Test)
COM_INTERFACE_ENTRY(ITest)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()

__event __interface ITestEvents;


public:
HRESULT OnTestEvent(ITest *pITest)
{
return S_OK;
}


HRESULT FinalConstruct()
{
__hook(&ITestEvents::TestEvent, static_cast<ITest*>(this),
&Test::OnTestEvent);
return S_OK;
}



};


I see the compiler error "error C2039: 'OnTestEvent' : is not a member of
'Test'". Anyone else with the same error?


Anybody got a good hint for me what is wrong?

Ronny
 
B

Ben Voigt [C++ MVP]

Masterchief said:
HY!

I have a problem hooking an event. I get an compiler error, that my
callback isn´t a memeber of the containing class. I canßt find anything I
am doing wrong.
I found a small coed example which reproduces the compiler error.

[object, uuid("99BE5DDB-0661-496E-BA84-8DE522E817C9"), dual,
oleautomation]
__interface ITest
{



};


[dispinterface, uuid("C3D67614-608A-44D1-BA7D-9586A21C14F4")]
__interface ITestEvents
{
[id(1)]
HRESULT TestEvent([in] ITest *pITest);


};


[coclass, uuid("D3EDEB8D-0756-4705-B167-3939DD480DF3"), event_source(com),
event_receiver(com)]
class ATL_NO_VTABLE Test : public ITest
{
BEGIN_COM_MAP(Test)
COM_INTERFACE_ENTRY(ITest)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()

__event __interface ITestEvents;


public:
HRESULT OnTestEvent(ITest *pITest)
{
return S_OK;
}


HRESULT FinalConstruct()
{
__hook(&ITestEvents::TestEvent, static_cast<ITest*>(this),
&Test::OnTestEvent);
return S_OK;
}



};


I see the compiler error "error C2039: 'OnTestEvent' : is not a member of
'Test'". Anyone else with the same error?


Anybody got a good hint for me what is wrong?

The group for native development is microsoft.public.vc.language.

Have you tried using a static member function?
 
M

Masterchief

Hy!

Yes. I have. I also changend the calling convention to __stdcall.
Nothing helps.

Ronny

Ben Voigt said:
Masterchief said:
HY!

I have a problem hooking an event. I get an compiler error, that my
callback isn´t a memeber of the containing class. I canßt find anything I
am doing wrong.
I found a small coed example which reproduces the compiler error.

[object, uuid("99BE5DDB-0661-496E-BA84-8DE522E817C9"), dual,
oleautomation]
__interface ITest
{



};


[dispinterface, uuid("C3D67614-608A-44D1-BA7D-9586A21C14F4")]
__interface ITestEvents
{
[id(1)]
HRESULT TestEvent([in] ITest *pITest);


};


[coclass, uuid("D3EDEB8D-0756-4705-B167-3939DD480DF3"),
event_source(com),
event_receiver(com)]
class ATL_NO_VTABLE Test : public ITest
{
BEGIN_COM_MAP(Test)
COM_INTERFACE_ENTRY(ITest)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()

__event __interface ITestEvents;


public:
HRESULT OnTestEvent(ITest *pITest)
{
return S_OK;
}


HRESULT FinalConstruct()
{
__hook(&ITestEvents::TestEvent, static_cast<ITest*>(this),
&Test::OnTestEvent);
return S_OK;
}



};


I see the compiler error "error C2039: 'OnTestEvent' : is not a member of
'Test'". Anyone else with the same error?


Anybody got a good hint for me what is wrong?

The group for native development is microsoft.public.vc.language.

Have you tried using a static member function?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top