change page encoding in WebBrowser ActiveX control
How to change the page encoding in Web Browser AxtiveX control? Currently I make:
HRESULT hr;
CComPtr<IDispatch> disp = this->GetHtmlDocument();
CComPtr<IHTMLDocument2> m_doc = NULL;
hr = disp->QueryInterface(&m_doc);
if (SUCCEEDED(hr))
{
m_doc->put_charset(CComBSTR("windows-1251"));
CComPtr<IHTMLElementCollection> m_pElemCollection;
CComBSTR Text;
hr = m_doc->get_all(&m_pElemCollection); // get collection
if (SUCCEEDED(hr))
{
long cntr;
hr = m_pElemCollection->get_length(&cntr); // get lenght
if (SUCCEEDED(hr))
{
for (int i = 0; i<cntr; i++) // all collection
{
VARIANT vIndex;
vIndex.vt = VT_I4;
vIndex.intVal = i;
IDispatch* pDisp = NULL;
m_pElemCollection->item(vIndex, vIndex, &pDisp);
IHTMLMetaElement* m_Meta = NULL;
hr = pDisp->QueryInterface (&m_Meta);
if (SUCCEEDED(hr))
{
m_Meta->put_charset(CComBSTR("windows-1251"));
m_Meta->Release();
}
pDisp->Release();
}
}
}
// hr = m_doc->put_defaultCharset(CComBSTR("windows-1251"));
// CComPtr<IHTMLLocation> pLoc = NULL;
// m_doc->get_location (&pLoc);
// hr = pLoc->reload(VARIANT_FALSE);
}
and nothing changes, it doesn't work. Could you please advise on what to do?
|