Click here to Skip to main content
15,883,749 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I have an add-in project which creates toolbar written by vs 2005, now when I convert it into 2010 it doesn't work. It returns CONNECT_E_NOCONNECTION when I call DispEventAdvise() function. Could You help me?

Here is the steps of debugging :
C++
CComQIPtr<iunknown,> spUnk(m_pButton);
hr = CCommandButt1Events::DispEventAdvise(spUnk);

1.
C++
HRESULT DispEventAdvise(_Inout_ IUnknown* pUnk)
    {
        return _IDispEvent::DispEventAdvise(pUnk, pdiid);
    }

2.
C++
HRESULT DispEventAdvise(
        _Inout_ IUnknown* pUnk,
        _In_ const IID* piid)
    {
        ATLENSURE(m_dwEventCookie == 0xFEFEFEFE);
        return AtlAdvise(pUnk, (IUnknown*)this, *piid, &m_dwEventCookie);
    }

3.
C++
ATLINLINE ATLAPI AtlAdvise(
    _Inout_ IUnknown* pUnkCP,
    _Inout_opt_ IUnknown* pUnk,
    _In_ const IID& iid,
    _Out_ LPDWORD pdw)
{
    if(pUnkCP == NULL)
        return E_INVALIDARG;

    CComPtr<iconnectionpointcontainer> pCPC;
    CComPtr<iconnectionpoint> pCP;
    HRESULT hRes = pUnkCP->QueryInterface(__uuidof(IConnectionPointContainer), (void**)&pCPC);
    if (SUCCEEDED(hRes))
        hRes = pCPC->FindConnectionPoint(iid, &pCP);
    if (SUCCEEDED(hRes))
        hRes = pCP->Advise(pUnk, pdw);
    return hRes;
}


The call of hRes = pCPC->FindConnectionPoint(iid, &pCP) function returns CONNECT_E_NOCONNECTION value.
Posted
Updated 14-May-12 4:26am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900