Drawing Control, Connector Tool, and C++

S

Scott Metzger

Hi,

Ok, How do I enable the Connector tool in a C++ application that uses
the Drawing Control? I have studied the example in C#, but have been
unable to get it working with C++ in an MFC application.

Here is what I have so far...
void CVisioForm::OnConnectionTool(void)
{// MyDrawing is an instance of the Drawing Control
CVDocument myDocument(MyDrawing.get_Document());
CVApplication myApplication(myDocument.get_Application());

LPDISPATCH pDisp;
LPOLECOMMANDTARGET pCmdTarg = NULL;

pDisp = myApplication.m_lpDispatch;
pDisp->QueryInterface(IID_IOleCommandTarget, (LPVOID*)&pCmdTarg);
// pCmdTarg is NULL

pDisp = LPDISPATCH(myApplication);
pDisp->QueryInterface(IID_IOleCommandTarget, (LPVOID*)&pCmdTarg);
// pCmdTarg is still NULL

pCmdTarg->Exec(NULL, visCmdDRConnectionTool, 0, NULL, NULL);

if (pCmdTarg)
pCmdTarg->Release();
if (pDisp)
pDisp->Release();
}

It seems no matter what IDispatch I use to call QueryInterface I always
get a NULL pointer for my pCmdTarg. I have tried not only the above but
also every method for CVApplication that returns an LPDISPATCH as well
as several methods for CDrawingControl and CVDocument.

Is my above code fundementally wrong? Or am I getting the 'wrong'
LPDISPATCH?

Also, I suspect that my first param in my call to pCmdTarg should _not_
be NULL. What should I pass here? the CLSID?

Thanks,
Scott Metzger
 

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