Event handling problem.

H

Haakon S.

I try to use the Visio ActiveX Control via a SDI application developed with
Visual C++ 6.0. Here's what I do:

I use Class Wizzard to create the class MFCSink derived from CCmdTarget. I
activate automation for the class. Further, in the class i define the function

void MFCSink::evtNotify(LPDISPATCH pDisp).

In the same file under the BEGIN_DISPATCH_MAP macro i specify:

DISP_FUNCTION_ID(MFCSink, "evtNotify",1,evtNotify, VT_EMPTY, VTS_DISPATCH)

In my CView-derived class I include the member MFCSink m_sink. Under the
InitialUpdate function of this file I specify:

LPDISPATCH pDisp=m_sink.GetIDispatch(FALSE);
VARIANT vartag=_variant_t(pDisp);

CVWindow wnd = m_DrawCtrl.GetWindow();
CVEventList eventlist=wnd.GetEventList();

eventlist.AddAdvise((short)visEvtAdd|(short)visEvtShape,vartag,"evtNotify",VTS_DISPATCH);

I have tried several alternatives instead of the last VTS_DISPATCH
parameter. The compiler never complains, but Visio comes up with a message
box saying "Invalid parameter" and the evtNotify function is never activated.

Can anybody please explain what I'm doing wrong here?

Regards, Haakon S.
 

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