Article ID: 196340
Article Last Modified on 5/12/2004
// Get the IDispatch of the document
LPDISPATCH lpDisp = NULL;
lpDisp = m_webBrowser.GetDocument();
if (lpDisp)
{
IOleContainer* pContainer;
// Get the container
HRESULT hr = lpDisp->QueryInterface(IID_IOleContainer,
(void**)&pContainer);
lpDisp->Release();
if (FAILED(hr))
return hr;
IEnumUnknown* pEnumerator;
// Get an enumerator for the frames
hr = pContainer->EnumObjects(OLECONTF_EMBEDDINGS, &pEnumerator);
pContainer->Release();
if (FAILED(hr))
return hr;
IUnknown* pUnk;
ULONG uFetched;
// Enumerate and refresh all the frames
for (UINT i = 0; S_OK == pEnumerator->Next(1, &pUnk, &uFetched); i++)
{
IWebBrowser2* pBrowser;
hr = pUnk->QueryInterface(IID_IWebBrowser2, (void**)&pBrowser);
pUnk->Release();
if (SUCCEEDED(hr))
{
// Refresh the frame
pBrowser->Refresh();
pBrowser->Release();
}
}
pEnumerator->Release();
}Note ActiveX controls hosted in an HTML page can use this technique in a
similar manner. In general, an ActiveX control that accesses the unsafe
WebBrowser Object Model is not safe for scripting and should implement
IObjectSafety interface accordingly for security.
Additional query words: WebBrowser Frame
Keywords: kbfaq kbhowto kbwebbrowser KB196340