Example #1
0
HRESULT CPolyCommand::initialize()
{
    HRESULT hr = S_OK;

    try {
        // Get an instance of a wrapper for a non-db-resident polygon
        if (FAILED(hr = m_pPoly.CoCreateInstance(CLSID_ComPolygon))) {
            // most likely problem, be a little more descriptive here
            acutPrintf("\nUnable to load ComPolygon");
            throw hr;
        }

        // Get the base object - needed for those methods inherited by polygon
        m_pBaseObj = m_pPoly;
        m_pBaseObj->CreateObject();

        // Get an instance of a listner so we know when input has been
        // entered in OPM
        if (FAILED(hr = CComObject<CComPolyCmd>::CreateInstance(&m_pPolyCmd)))
            throw hr;

        m_pPolyCmd->SetDocument(curDoc());
        hr = m_pPolyCmd->QueryInterface(IID_IUnknown,(LPVOID *)&m_pUnkCmd);
        if (FAILED(hr))
            throw hr;

        // Attach the listener to the polygon wrapper
        CComQIPtr<IConnectionPointContainer> pPtContainer;
        pPtContainer = m_pPoly;
        hr = pPtContainer->FindConnectionPoint(
            IID_IPropertyNotifySink,&m_pConPt);
        if (FAILED(hr))
            throw hr;

        if (FAILED(hr = m_pConPt->Advise(m_pUnkCmd,&m_dConnectionID)))
            throw hr;

        acedSetIUnknownForCurrentCommand(m_pPoly);

        m_pDb = curDoc()->database();

        setDefaults();

    } catch (HRESULT) {
        fail();
    }
    return hr;
}
Example #2
0
void IISxpressAPI::ResponseHistory::AttachConnectionPoint()
{
	m_dwCookie = 0;
	m_pHTTPNotifyCP = nullptr;

	if (m_pNotifyObj == nullptr)
	{
		// TODO: a better error message here
		throw gcnew System::Exception();
	}

	CComPtr<IIISxpressHTTPRequest> pHTTPRequest;
	HRESULT hr = GetHTTPRequest(&pHTTPRequest);
	if (hr != S_OK)
	{
		throw gcnew IISxpressAPI::IISxpressAPIException(hr);
	}

	CComQIPtr<IConnectionPointContainer> pConnPointCont = pHTTPRequest;
	if (pConnPointCont != NULL)
	{				
		if (pConnPointCont != NULL)
		{					
			CComPtr<IConnectionPoint> pHTTPNotifyCP;
			HRESULT hr = pConnPointCont->FindConnectionPoint(IID_IIISxpressHTTPNotify, &pHTTPNotifyCP);
			if (pHTTPNotifyCP != NULL)
			{
				CComPtr<IUnknown> pUnk;
				m_pNotifyObj->QueryInterface(IID_IUnknown, (void**) &pUnk);
		
				DWORD dwCookie = 0;
				hr = pHTTPNotifyCP->Advise(pUnk, &dwCookie);

				m_pHTTPNotifyCP = pHTTPNotifyCP.Detach();
				m_dwCookie = dwCookie;
			}
		}
	}
}