How do you access an IFRAME?

Posted on 2006-04-11
Last Modified: 2010-04-01
How do you access an IFRAME using C++?
Question by:jclemen11
    1 Comment
    LVL 86

    Accepted Solution

    Using an IHTML2Documant and an IHTMLCollection, you can do that like

            HRESULT hr = spHTML->get_all(&spAll);
            if (SUCCEEDED(hr) && spAll)
                long nCnt = 0;
                HRESULT  hr = spAll->get_length(&nCnt);
                if  (SUCCEEDED(hr) && nCnt  >0)

                for (long i = 0;  i <  nCnt; i++)
                        CComVariant varIdx;
                        V_VT(&varIdx) = VT_I4;
                        V_I4(&varIdx) = i;

                        CComPtr<IDISPATCH> spElemDisp;
                        hr = spAll->item(varIdx, varIdx, &spElemDisp);
                        if (SUCCEEDED(hr) && spElemDisp)
                            CComQIPtr<IHTMLFRAMEBASE2 &IID_IHTMLFrameBase2,>
                            if (spFrame)
                                // This is a frame or iframe element.  
                                CComPtr<IHTMLWINDOW2> spWin;
                                hr = spFrame->get_contentWindow(&spWin);
                                if (SUCCEEDED(hr) && spWin)
                                    CComPtr<IHTMLDOCUMENT2> spDoc;
                                    hr = spWin->get_document(&spDoc);
                                    if (SUCCEEDED(hr) && spDoc)

    (Code taken from - "Popup Blocker")

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
    Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
    The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
    The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now