Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2004, 07:28 AM
Registered User
 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?

 
Old December 16th, 2004, 03:10 PM
Registered User
 
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Anybody know this problem decision?
Please help.


 
Old December 16th, 2004, 07:08 PM
Registered User
 
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

    switch (dispIdMember)
    {
    case DISPID_DOWNLOADCOMPLETE:
        break;
    case DISPID_DOCUMENTCOMPLETE:
        {
            LPDISPATCH lpDisp;
            CComQIPtr<IHTMLDocument2> pDoc2;
            CComQIPtr<IHTMLElement> pElem;
            VARIANT vAttrVal;
            CComBSTR cbValue;
            TCHAR szCharset[]=_T("utf-8");

            m_pMainWB->get_Document(&lpDisp);
            hRes=lpDisp->QueryInterface(IID_IHTMLDocument2,(void**)&pDoc2) ;
            if(SUCCEEDED(hRes))
            {
                hRes=pDoc2->get_charset(&cbValue);
                if(lstrcmp(szCharset,OLE2T(cbValue))==0)
                {
                    //
                }else
                {
                    hRes=pDoc2->put_charset(T2BSTR(szCharset));
                    _variant_t rl=1L; // this is
                    hRes=m_pMainWB->Refresh2(&rl); // decision
                }
        }
        break;
    default:
        return DISP_E_MEMBERNOTFOUND;
    }





Similar Threads
Thread Thread Starter Forum Replies Last Post
Webbrowser control mussie C# 2005 1 March 2nd, 2010 01:10 PM
HOWTO VB2008: VB6 ActiveX /WebBrowser Philibuster Visual Basic 2008 Essentials 1 August 11th, 2008 09:59 PM
encoding change for Greeks! jmjyiannis ASP.NET 1.0 and 1.1 Professional 0 September 16th, 2005 07:24 AM
Change TextBox control location on aspx page minhpx General .NET 2 March 4th, 2005 08:29 AM
WebBrowser control atingoldy Beginning VB 6 1 June 16th, 2003 06:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.