描述:
I'm writing a small control to remotely navigate an HTML
page in a browser. The technique for getting the
IHTMLDocument2 interface for the hosting web page seems
well documented, but I can't make it work.
I am implementing IObjectWithSite as follows:
public IObjectWithSiteImpl<CCTest>,
COM_INTERFACE_ENTRY(IObjectWithSite)
then using the code
CComPtr<IOleContainer> spContainer;
m_spClientSite->GetContainer(&spContainer);
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2>
spDoc(spContainer);
but getting the error:
'm_spClientSite' : undeclared identifier
This is extremely frustrating. After several hours I'm
giving up and appealing for help!
解决方案1:
m_spClientSite is a member of IOleObjectImpl, which you don't derive
from. IObjectWithSiteImpl has m_spUnkSite member. Try querying it for
IOleClientSite.