How to control the behavior of IE

Source: Internet
Author: User

Here's a way to control ie for refreshing:

First step, create

SHDocVw::IShellWindowsPtr m_spSHWinds;
if (m_spSHWinds == NULL){
        if (m_spSHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows)) != S_OK){
           MessageBox("Failed");
           CoUninitialize();
           EndDialog(1);
        }
    }

Step two, get all the currently open IE windows

if (m_spSHWinds){
        int n = m_spSHWinds->GetCount();
        for (int i = 0; i < n; i++){
           _variant_t v = (long)i;
           IDispatchPtr spDisp = m_spSHWinds->Item(v);
SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);  //生成一个IE窗口的智能指针
           if (spBrowser){
               _bstr_t bsName = spBrowser->GetLocationName();  //窗口名称
               int nPos = m_ctrlIE.InsertItem(0, bsName);
               spBrowser->AddRef();
               void * pData = spBrowser;
               m_ctrlIE.SetItemData(nPos, (DWORD)(pData));
           }
        }
    }

Third step, refresh IE window

Pbrowser->refresh (); Pbrowser Point to Shdocvw::iwebbrowser2ptr

Of course, we have access to the IE window after the IWebBrowser2, we can control the IE, such as reading the content of the settings element, as well as some other more control, reference Iwebbrowser2,ihtmldocument2, etc.!!!!

Compilation Environment Win2000 Professional + VC6.0 (en) + sp5.0 + Platform SDK 2001.8

Test passes under Win2000 Professional, such as compilation however, please download the latest platform SDK

This article supporting source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.