コード例 #1
0
ファイル: Js2nCtrl.cpp プロジェクト: xgc820313/js2n
void CJs2nCtrl::OnSetClientSite() 
{
	// TODO: Add your specialized code here and/or call the base class
	LPOLECLIENTSITE pClientSite = GetClientSite();

	if (pClientSite != NULL)
	{
		// Obtain URL from container moniker.
		IMoniker*	ppmk;
		LPOLESTR	pszDisplayName;

		if (SUCCEEDED(pClientSite->GetMoniker( OLEGETMONIKER_TEMPFORUSER,
											   OLEWHICHMK_CONTAINER,
											   &ppmk)))
		{
			if (SUCCEEDED(ppmk->GetDisplayName(NULL, NULL, &pszDisplayName)))
			{
				PString strURL( (WORD *)pszDisplayName );
				PString strPluginsPath = FindPluginsPath();
				m_NativeLogic.Init( strURL, strPluginsPath );
				CoTaskMemFree((LPVOID)pszDisplayName);
			}
		}
	}

	COleControl::OnSetClientSite();
}
コード例 #2
0
ファイル: fsNVRPluginCtrl.cpp プロジェクト: mildrock/Media
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();
}
コード例 #3
0
ファイル: plugin.cpp プロジェクト: paa/vlc
HRESULT VLCPlugin::onLoad(void)
{
    if( SysStringLen(_bstr_baseurl) == 0 )
    {
        /*
        ** try to retreive the base URL using the client site moniker, which for Internet Explorer
        ** is the URL of the page the plugin is embedded into.
        */
        LPOLECLIENTSITE pClientSite;
        if( SUCCEEDED(vlcOleObject->GetClientSite(&pClientSite)) && (NULL != pClientSite) )
        {
            IBindCtx *pBC = 0;
            if( SUCCEEDED(CreateBindCtx(0, &pBC)) )
            {
                LPMONIKER pContMoniker = NULL;
                if( SUCCEEDED(pClientSite->GetMoniker(OLEGETMONIKER_ONLYIFTHERE,
                                OLEWHICHMK_CONTAINER, &pContMoniker)) )
                {
                    LPOLESTR base_url;
                    if( SUCCEEDED(pContMoniker->GetDisplayName(pBC, NULL, &base_url)) )
                    {
                        /*
                        ** check that the moniker name is a URL
                        */
                        if( UrlIsW(base_url, URLIS_URL) )
                        {
                            /* copy base URL */
                            _bstr_baseurl = SysAllocString(base_url);
                        }
                        CoTaskMemFree(base_url);
                    }
                }
            }
        }
    }
    setDirty(FALSE);
    return S_OK;
};
コード例 #4
0
void
ieambulant_display_message(int level, const char* message) {
	USES_CONVERSION;

	HRESULT hr = E_FAIL;
	if ( ! s_site)
		return;

	IServiceProvider* pISP = NULL;
	hr = s_site->QueryInterface(IID_IServiceProvider, (void **)&pISP);
	if ( ! SUCCEEDED(hr))
		return;
	// get IWebBrowser2
	IWebBrowser2* pIWebBrowser2 = NULL;
	hr = pISP->QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, (void **)&pIWebBrowser2);
	pISP->Release();
	if ( ! SUCCEEDED(hr) || pIWebBrowser2 == NULL)
		return;
	IDispatch *pIDispatchDocument = NULL;
	hr = pIWebBrowser2->get_Document(&pIDispatchDocument);
	pIWebBrowser2->Release();
	if ( ! SUCCEEDED(hr) || pIDispatchDocument == NULL)
		return;
	// get IHTMLDocument2
	IHTMLDocument2* pIHTMLDocument2 = NULL;
	hr = pIDispatchDocument->QueryInterface(IID_IHTMLDocument2, (void **)&pIHTMLDocument2);
	pIDispatchDocument->Release();
	if ( ! SUCCEEDED(hr) || pIHTMLDocument2 == NULL)
		return;
	// get IHTMLWindow2
	IHTMLWindow2* pIHTMLWindow2 = NULL;
	hr = pIHTMLDocument2->get_parentWindow(&pIHTMLWindow2);
	pIHTMLDocument2->Release();
	if ( ! SUCCEEDED(hr) || pIHTMLWindow2 == NULL)
		return;
	CString Cstr_message(message);
	BSTR BSTR_message = Cstr_message.AllocSysString();
	pIHTMLWindow2->put_status(BSTR_message);
	SysFreeString(BSTR_message);
	pIHTMLWindow2->Release();
}
コード例 #5
0
bool CGifSmileyCtrl::CopySmile( long hwndHostWindow, BSTR bstrFileName, OLE_COLOR clr, INT cy)
{
	COLORREF backColor = (COLORREF)(clr);
	HWND hwnd = (HWND)(hwndHostWindow);
	HRESULT hr; 

	LPOLECLIENTSITE pOleSite;
	LPOLEOBJECT	lpObject=NULL;
	LPLOCKBYTES lpLockBytes = NULL;  

	// retrieve OLE interface for richedit  

	try
	{ 

		IOleObject *lpOleObject = NULL;    //OLE object
		QueryInterface(IID_IOleObject,(void**)&lpOleObject); 
		lpOleObject->GetClientSite(&pOleSite);

		//Load the gif
		LoadFromFileSized(bstrFileName, 0,cy);

		//Set back color
		OLE_COLOR oleBackColor=(OLE_COLOR)backColor;
		m_clrBackColor = oleBackColor;
		put_BackColor(oleBackColor);
		//myObject->put_BackColor(oleBackColor);

		//get the IOleObject
		hr = QueryInterface(IID_IOleObject, (void**)&lpObject);
		if (FAILED(hr))
		{
			return	 false;
		}

		//to insert into richedit, you need a struct of REOBJECT
		REOBJECT reobject;
		ZeroMemory(&reobject, sizeof(REOBJECT));

		reobject.cbStruct = sizeof(REOBJECT);	

		CLSID clsid;
		hr =  lpObject->GetUserClassID(&clsid);


		//set clsid
		reobject.clsid = clsid;
		//can be selected
		reobject.cp = REO_CP_SELECTION;
		//content, but not static
		reobject.dvaspect = DVASPECT_CONTENT;
		//goes in the same line of text line
		reobject.dwFlags = REO_BELOWBASELINE;
		reobject.dwUser = (DWORD)this;
		//the very object
		reobject.poleobj = lpObject;
		//client site contain the object
		reobject.polesite = pOleSite;
		//the storage 
		reobject.pstg = NULL;

		SIZEL sizel={0};
		reobject.sizel = sizel; 
		hr = SetHostWindow((long)hwnd, 0);

		//ole->InsertObject(&reobject);

		//redraw the window to show animation
		::RedrawWindow(hwnd,NULL, NULL, RDW_INVALIDATE);

		if (pOleSite)
		{
			pOleSite->Release();
			pOleSite = NULL;
		}
		if (lpObject)
		{
			lpObject->Release();
			lpObject = NULL;
		} 
	}
	catch( ... )
	{
		if (pOleSite)
		{
			pOleSite->Release();
			pOleSite = NULL;
		}
		if (lpObject)
		{
			lpObject->Release();
			lpObject = NULL;
		} 
		return FALSE;
	}
	return S_OK;
}
コード例 #6
0
ファイル: UIIMEdit.cpp プロジェクト: vonway/teamtalk-win
void UIIMEdit::InsertImage(BSTR bstrFileName,SIZE size,BOOL isGif)
{
	LPSTORAGE lpStorage = NULL;
	LPOLEOBJECT	lpObject = NULL;
	LPLOCKBYTES lpLockBytes = NULL;
	LPOLECLIENTSITE lpClientSite = NULL;
	GifSmiley::IGifSmileyCtrl* lpAnimator = nullptr;
	HRESULT hr = ::CoCreateInstance(GifSmiley::CLSID_CGifSmileyCtrl, NULL, CLSCTX_INPROC, GifSmiley::IID_IGifSmileyCtrl, (LPVOID*)&lpAnimator);
	if (NULL == lpAnimator || FAILED(hr))
	{
		LOG__(ERR, _T("InsertImage CoCreateInstance failed"));
		goto End;
	}

	COLORREF backColor = (COLORREF)(::GetSysColor(COLOR_WINDOW));
	HWND hwnd = (HWND)((long)m_pManager->GetPaintWindow());
	IRichEditOle *pRichEditOle = m_pRichEditOle;
	if (NULL == pRichEditOle)
		goto End;
	BSTR path = NULL;
	//Create lockbytes
	hr = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
	if (FAILED(hr))
	{
		LOG__(ERR, _T("InsertImage CreateILockBytesOnHGlobal failed"));
		goto End;
	}
	//use lockbytes to create storage
	SCODE sc = ::StgCreateDocfileOnILockBytes(lpLockBytes, STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_READWRITE, 0, &lpStorage);
	if (sc != S_OK)
	{
		LOG__(ERR, _T("InsertImage StgCreateDocfileOnILockBytes failed"));
		goto End;
	}
	// retrieve OLE interface for richedit   and  Get site
	pRichEditOle->GetClientSite(&lpClientSite);
	try
	{
		//COM operation need BSTR, so get a BSTR
		path = bstrFileName;
		//Load the image
		if (isGif)
			lpAnimator->LoadFromFile(path);
		else
		{
			UInt32 height = (size.cy < GetHeight()) ? size.cy : GetHeight();
			UInt32 width = (size.cx < GetWidth() / 2) ? size.cx : GetWidth() / 2;
			lpAnimator->LoadFromFileSized(path, width, height);
		}
		//Set back color
		OLE_COLOR oleBackColor = (OLE_COLOR)backColor;
		lpAnimator->put_BackColor(oleBackColor);
		//get the IOleObject
		hr = lpAnimator->QueryInterface(IID_IOleObject, (void**)&lpObject);
		if (FAILED(hr))
		{
			LOG__(ERR, _T("InsertImage lpAnimator QueryInterface failed"));
			goto End;
		}
		//Set it to be inserted
		OleSetContainedObject(lpObject, TRUE);
		//to insert into richedit, you need a struct of REOBJECT
		REOBJECT reobject;
		ZeroMemory(&reobject, sizeof(REOBJECT));
		reobject.cbStruct = sizeof(REOBJECT);
		CLSID clsid;
		hr = lpObject->GetUserClassID(&clsid);
		//set clsid
		reobject.clsid = clsid;
		//can be selected
		reobject.cp = REO_CP_SELECTION;
		//content, but not static
		reobject.dvaspect = DVASPECT_CONTENT;
		//goes in the same line of text line
		reobject.dwFlags = REO_BELOWBASELINE;
		//reobject.dwUser = (DWORD)myObject;
		//the very object
		reobject.poleobj = lpObject;
		//client site contain the object
		reobject.polesite = lpClientSite;
		//the storage 
		reobject.pstg = lpStorage;
		SIZEL sizel = { 0 };
		reobject.sizel = sizel;
		LPOLECLIENTSITE lpObjectClientSite = NULL;
		hr = lpObject->GetClientSite(&lpObjectClientSite);
		if (FAILED(hr) || lpObjectClientSite == NULL)
			lpObject->SetClientSite(lpClientSite);
		pRichEditOle->InsertObject(&reobject);
		//redraw the window to show animation
		::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE);
	}
	catch (...)
	{
		LOG__(ERR, _T("InsertImage unknown exeption"));
	}

End:
	if (lpClientSite)
	{
		lpClientSite->Release();
		lpClientSite = nullptr;
	}
	if (lpObject)
	{
		lpObject->Release();
		lpObject = nullptr;
	}
	if (lpLockBytes)
	{
		lpLockBytes->Release();
		lpLockBytes = nullptr;
	}
	if (lpStorage)
	{
		lpStorage->Release();
		lpStorage = nullptr;
	}
	if (lpAnimator)
	{
		lpAnimator->Release();
		lpAnimator = nullptr;
	}
}
コード例 #7
0
ファイル: freeWRLCtrl.cpp プロジェクト: Displacer/freewrl
void CfreeWRLCtrl::DoPropExchange(CPropExchange* pPX)
{
#define MESSBOX 1
#undef MESSBOX
#ifdef MESSBOX //_DEBUGn
		AfxMessageBox("doPropExchange m_initialized="+m_initialized); //"DoPropExchange");
#endif
	ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
	COleControl::DoPropExchange(pPX);
	USES_CONVERSION;


	//PX_String(pPX, "SRC", m_cstrFileName); 

	// TODO: Call PX_ functions for each persistent custom property.
	//HTML <OBJECT> tends to generate two DoPropExchanges, HREF and EMBED just one, 
	// so we'll fetch SRC on the first
	if(m_initialized / 10 == 0) 
	{

		// MimeType sample program says SRC property is where Mime handler 
		//   passes in URL
	  if(PX_String(pPX, "SRC", m_cstrFileName)){
		//AfxMessageBox(m_cstrFileName);

		// http://support.microsoft.com/kb/181678 How to Retrieve the URL of a Web Page from an ActiveX Control
		//m_cstrContainerURL = NULL; //C++ initializes these I think.
		LPOLECLIENTSITE pClientSite = this->GetClientSite();
		if (pClientSite != NULL)
		{
			// Obtain URL from container moniker.
			CComPtr<IMoniker> spmk;
			LPOLESTR pszDisplayName;

			if (SUCCEEDED(pClientSite->GetMoniker(
											OLEGETMONIKER_TEMPFORUSER,
											OLEWHICHMK_CONTAINER,
											&spmk)))
			{
				if (SUCCEEDED(spmk->GetDisplayName(
										NULL, NULL, &pszDisplayName)))
				{

					CComBSTR bstrURL;
					bstrURL = pszDisplayName;
					//AfxMessageBox(OLE2T(bstrURL));
					m_cstrContainerURL = OLE2T(bstrURL);
					//ATLTRACE("The current URL is %s\n", OLE2T(bstrURL));
					CoTaskMemFree((LPVOID)pszDisplayName);
				}
			}
		}
		//AfxMessageBox("containerURL="+m_cstrContainerURL);
		//AfxMessageBox("fileName="+m_cstrFileName); //"DoPropExchange");
		if(m_cstrContainerURL != m_cstrFileName)
		{
			//they are different, so concatonate
			int lastSlash = m_cstrContainerURL.ReverseFind('/');
			m_cstrContainerURL = m_cstrContainerURL.Left(lastSlash);
			if(m_cstrContainerURL.GetLength() > 0)
				m_cstrFileName = m_cstrContainerURL + "/" + m_cstrFileName;
		}
#define MESSBOX 1
#undef MESSBOX
#ifdef MESSBOX //_DEBUGn
		AfxMessageBox(m_cstrFileName); //"DoPropExchange");
#endif
		//m_Hwnd = (void *)0; //an unlikely real handle value, and not null either 
		m_initialized += 10; //10 means we have a filename
	 // }else{
		//AfxMessageBox("get SRC failed");
	  }
	}
}