You're on the right track. But missing one detail - IOleObject::GetClientSite Here's a code snip that I used in a recent ATL based ActiveX control to get the IHTMLDocument2 interface of the parent IE WebBrowser. Sure it goes a little farther than what you want by getting the document (one extra call), but it demonstrates the concept.
inline HRESULT GetIEDocument(IOleObject* pObject, IHTMLDocument2 ** ppDocument2 )
{
CComPtr<IOleClientSite> spClientSite;
CComPtr<IServiceProvider> spSrvProv;
CComPtr<IWebBrowser2> spWebBrowser;
CComPtr<IHTMLDocument2> spHTMLDoc2;
// Param check
if( !ppDocument2 || !pObject )
{
ATLASSERT(!"Bad pointer param");
return E\_POINTER;
}
//
// Dig our way up to the Document that contains us
//
HRESULT hr = pObject->GetClientSite((IOleClientSite \*\*)&spClientSite);
if( FAILED(hr) )
return hr;
hr = spClientSite->QueryInterface(IID\_IServiceProvider, (void \*\*)&spSrvProv);
if( FAILED(hr) )
return hr;
hr = spSrvProv->QueryService(SID\_SWebBrowserApp, IID\_IWebBrowser2, (void \*\*)&spWebBrowser);
if( FAILED(hr) )
return hr;
hr = spWebBrowser->get\_Document((LPDISPATCH\*)&spHTMLDoc2);
if( FAILED(hr) )
return hr;
//
// All Done
//
(\*ppDocument2) = spHTMLDoc2;
(\*ppDocument2)->AddRef();
return S\_OK;
}
BTW, To the best of my knowlege ActiveX controls don't work in Nutscrape. Did you find a way for them to work? [ Jason De Arte | Toy Maker | 1001010.com ]