Ejemplo n.º 1
0
void CfsNVRPluginCtrl::OnSetClientSite()
{
	// TODO: 在此添加专用代码和/或调用基类
	try
	{
		LPOLECLIENTSITE pClientSite = GetClientSite();
		LPOLECONTAINER  pOleContainer;
		if (pClientSite == NULL)
		{
			goto RET;
		}

		HRESULT hr = pClientSite->GetContainer(&pOleContainer);
		if (FAILED(hr))
		{
			goto RET;
		}

		IHTMLDocument* doc = NULL;
		hr =  pOleContainer->QueryInterface(IID_IHTMLDocument2,reinterpret_cast <void   **> (&doc)); 
		if (FAILED(hr))
		{
			goto RET;
		}

		IDispatch* script = NULL;
		hr = doc->get_Script(&script);
		doc->Release();
		if(FAILED(hr))
		{
			goto RET;
		}

		m_pScript = script;
	}
	catch (...)
	{

	}
RET:
	COleControl::OnSetClientSite();
}
Ejemplo n.º 2
0
void CEasyPDFCtrl::GetURL()
{
	USES_CONVERSION;  

	IOleContainer* pContainer = NULL;
	IHTMLDocument* pDoc = NULL;
	m_pClientSite->GetContainer( &pContainer );
	if ( pContainer != NULL )
	pContainer->QueryInterface( IID_IHTMLDocument, (void**)&pDoc );

	HRESULT hresult;
	OLECHAR FAR* szMember = T2W(_T("Initilize"));

	DISPID dispid;
	DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};

	IDispatch * pdisp = NULL;
	pDoc->get_Script(&pdisp);
	hresult = pdisp->GetIDsOfNames(IID_NULL,&szMember,1, LOCALE_SYSTEM_DEFAULT,&dispid);
	hresult = pdisp->Invoke(dispid,IID_NULL,LOCALE_USER_DEFAULT,DISPATCH_METHOD,&dispparamsNoArgs, NULL, NULL, NULL);
	pContainer->Release();
}