Button Event

M

Meier Rudolf

Hi

I created an Add-In for Word (2002). Now, when it loads I create a button,
then I connect to this button (ConnectionPoint, so that I can handle the
events). Now, the problem is, that it doesn't work. I don't get an error,
but the button "doesn't work". And at the end it can not be removed from the
commandbar. So ... I don't understand why. Can someone help me??

My CCommandHandler implements the ICommandBarButtonEvents and this is the
"Sink" function I use to connect to Word.
Is something wrong with this? Or where could I search the error? I checked
out, if the objects lifetime is long enough... and that's not the problem. I
tryed to find out if my "QueryInterface" returns a wrong value or pointer,
but it doesn't mather if I return a IDispatch* or a ICommandBarButtonEvents*
or another pointer... it just doesn't work.

void CCommandHandler::SinkEvents(LPDISPATCH pButton)

{

HRESULT hr;

// Get server's IConnectionPointContainer interface.

IConnectionPointContainer* pCPC;

hr = pButton->QueryInterface(IID_IConnectionPointContainer, (void **)&pCPC);

if (SUCCEEDED(hr)) {

// Find connection point for events we're interested in.

hr = pCPC->FindConnectionPoint(DIID__CommandBarButtonEvents,
&m_pConnection);

if (SUCCEEDED(hr)) {

hr = m_pConnection->Advise(static_cast<IUnknown*>(this), &m_dwCookie);

}

// Release the IConnectionPointContainer

pCPC->Release();

}

}
 

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