Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 16th, 2004, 07:28 AM
Registered User
 
Join Date: Jun 2004
Location: , , .
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?

Reply With Quote
  #2 (permalink)  
Old December 16th, 2004, 03:10 PM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Anybody know this problem decision?
Please help.


Reply With Quote
  #3 (permalink)  
Old December 16th, 2004, 07:08 PM
Registered User
 
Join Date: Dec 2004
Location: , , .
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;
    }
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:38 AM.


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