Ejemplo n.º 1
0
BOOL CATLDrawView::ConnectSink(REFIID iid, LPUNKNOWN punkSink)
{
	BOOL    bRC = FALSE;
	ASSERT(m_pDrawServ != NULL);

	LPCONNECTIONPOINTCONTAINER pConnPtCont;

	if ((m_pDrawServ != NULL) &&
		SUCCEEDED(m_pDrawServ->QueryInterface(IID_IConnectionPointContainer,
			(LPVOID*)&pConnPtCont)))
	{
		ATLENSURE(pConnPtCont != NULL);
		LPCONNECTIONPOINT pConnPt = NULL;

		HRESULT hRes = pConnPtCont->FindConnectionPoint(iid, &pConnPt);
		ASSERT(hRes == S_OK);
		if (SUCCEEDED(hRes))
		{
			ATLENSURE(pConnPt != NULL);
			hRes = pConnPt->Advise(punkSink, &m_dwDrawServ);
			if (FAILED(hRes))
			{
				TCHAR buf[32];
				wsprintf(buf, _T("%x"), hRes);
				AfxMessageBox(buf);
				return FALSE;
			}
			AfxMessageBox(_T("Connected"));
			bRC = TRUE;
			pConnPt->Release();
		}
		pConnPtCont->Release();
	}
	return bRC;
}
Ejemplo n.º 2
0
void cBrowser::Navigate( char* pURL )
{
	SafeStrCpy( m_szURL, pURL, 1024 );
	
	if( m_pWebBrowser ) 
	{ 
		LPCONNECTIONPOINTCONTAINER pCPC = NULL;
		LPCONNECTIONPOINT pCP = NULL;

		m_pWebBrowser->QueryInterface(IID_IConnectionPointContainer, (LPVOID*)&pCPC);
		pCPC->FindConnectionPoint(__uuidof(SHDocVw::DWebBrowserEventsPtr), &pCP);

		DWORD dwCookie;
		pCP->Advise((LPUNKNOWN)&m_events, &dwCookie);

		pCPC->Release();

//		CComVariant vempty, vUrl(m_szURL);
		CComVariant vempty;

		m_pWebBrowser->Navigate( _bstr_t(m_szURL), &vempty, &vempty, &vempty, &vempty);             

		pCP->Unadvise(dwCookie);
		pCP->Release();
	}
}