Ejemplo n.º 1
0
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();
}
Ejemplo n.º 2
0
Archivo: plugin.cpp Proyecto: 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;
};
Ejemplo n.º 3
0
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");
	  }
	}
}