Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to get all the frames of a web page(CHtmlView)?

How to get all the frames of a web page(CHtmlView)?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionannouncement
6 Posts 3 Posters 43 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tcpip2005
    wrote on last edited by
    #1

    I tried as bellow,but I think it doesn't work correctly. Who knows how?? Thank you very much. IHTMLDocument2 * pDoc = NULL; IHTMLWindow2 *pHTMLWnd = NULL; IHTMLDocument2 * pFrameDoc=NULL; IHTMLFramesCollection2 *pFramesCollection=NULL; LPDISPATCH lpDispatch; long p; VARIANT varindex,varresult; varresult.vt=VT_DISPATCH; varindex.vt = VT_I4; try { pDoc = (IHTMLDocument2*)(GetHtmlDocument()); if(pDoc!=NULL) { pDoc->get_frames(&pFramesCollection); if(pFramesCollection!=NULL) { pFramesCollection->get_length(&p); if(p>0) { for(int i=0; iitem(&varindex, &varresult) ==S_OK) { lpDispatch=(LPDISPATCH)varresult.ppdispVal; if (SUCCEEDED(lpDispatch->QueryInterface(IID_IHTMLWindow2, (LPVOID *)&pHTMLWnd))) { if(SUCCEEDED(pHTMLWnd->get_document( &pFrameDoc))) { BSTR bstr=NULL; HRESULT hr=pFrameDoc->get_URL(&bstr); ASSERT(SUCCEEDED(hr)); CString str= bstr; SysFreeString(bstr); pFrameDoc->Release(); pFrameDoc=NULL; } pHTMLWnd->Release(); pHTMLWnd=NULL; } } } } } } } catch(...) { }; try { if(pDoc != NULL) pDoc->Release(); if(pFramesCollection != NULL) pFramesCollection->Release(); } catch(...) { };

    T R 2 Replies Last reply
    0
    • T Tcpip2005

      I tried as bellow,but I think it doesn't work correctly. Who knows how?? Thank you very much. IHTMLDocument2 * pDoc = NULL; IHTMLWindow2 *pHTMLWnd = NULL; IHTMLDocument2 * pFrameDoc=NULL; IHTMLFramesCollection2 *pFramesCollection=NULL; LPDISPATCH lpDispatch; long p; VARIANT varindex,varresult; varresult.vt=VT_DISPATCH; varindex.vt = VT_I4; try { pDoc = (IHTMLDocument2*)(GetHtmlDocument()); if(pDoc!=NULL) { pDoc->get_frames(&pFramesCollection); if(pFramesCollection!=NULL) { pFramesCollection->get_length(&p); if(p>0) { for(int i=0; iitem(&varindex, &varresult) ==S_OK) { lpDispatch=(LPDISPATCH)varresult.ppdispVal; if (SUCCEEDED(lpDispatch->QueryInterface(IID_IHTMLWindow2, (LPVOID *)&pHTMLWnd))) { if(SUCCEEDED(pHTMLWnd->get_document( &pFrameDoc))) { BSTR bstr=NULL; HRESULT hr=pFrameDoc->get_URL(&bstr); ASSERT(SUCCEEDED(hr)); CString str= bstr; SysFreeString(bstr); pFrameDoc->Release(); pFrameDoc=NULL; } pHTMLWnd->Release(); pHTMLWnd=NULL; } } } } } } } catch(...) { }; try { if(pDoc != NULL) pDoc->Release(); if(pFramesCollection != NULL) pFramesCollection->Release(); } catch(...) { };

      T Offline
      T Offline
      Tcpip2005
      wrote on last edited by
      #2

      Code above doesn't look well . I paste it again . IHTMLDocument2 * pDoc = NULL; IHTMLWindow2 *pHTMLWnd = NULL; IHTMLDocument2 * pFrameDoc=NULL; IHTMLFramesCollection2 *pFramesCollection=NULL; LPDISPATCH lpDispatch; long p; VARIANT varindex,varresult; varresult.vt=VT_DISPATCH; varindex.vt = VT_I4; try { pDoc = (IHTMLDocument2*)(GetHtmlDocument()); if(pDoc!=NULL) { pDoc->get_frames(&pFramesCollection); if(pFramesCollection!=NULL) { pFramesCollection->get_length(&p); if(p>0) { for(int i=0; iitem(&varindex, &varresult) ==S_OK) { lpDispatch=(LPDISPATCH)varresult.ppdispVal; if (SUCCEEDED(lpDispatch->QueryInterface(IID_IHTMLWindow2, (LPVOID *)&pHTMLWnd))) { if(SUCCEEDED(pHTMLWnd->get_document( &pFrameDoc))) { BSTR bstr=NULL; HRESULT hr=pFrameDoc->get_URL(&bstr); ASSERT(SUCCEEDED(hr)); CString str= bstr; SysFreeString(bstr); pFrameDoc->Release(); pFrameDoc=NULL; } pHTMLWnd->Release(); pHTMLWnd=NULL; } } } } } } } catch(...) { }; try { if(pDoc != NULL) pDoc->Release(); if(pFramesCollection != NULL) pFramesCollection->Release(); } catch(...) { };

      H 1 Reply Last reply
      0
      • T Tcpip2005

        Code above doesn't look well . I paste it again . IHTMLDocument2 * pDoc = NULL; IHTMLWindow2 *pHTMLWnd = NULL; IHTMLDocument2 * pFrameDoc=NULL; IHTMLFramesCollection2 *pFramesCollection=NULL; LPDISPATCH lpDispatch; long p; VARIANT varindex,varresult; varresult.vt=VT_DISPATCH; varindex.vt = VT_I4; try { pDoc = (IHTMLDocument2*)(GetHtmlDocument()); if(pDoc!=NULL) { pDoc->get_frames(&pFramesCollection); if(pFramesCollection!=NULL) { pFramesCollection->get_length(&p); if(p>0) { for(int i=0; iitem(&varindex, &varresult) ==S_OK) { lpDispatch=(LPDISPATCH)varresult.ppdispVal; if (SUCCEEDED(lpDispatch->QueryInterface(IID_IHTMLWindow2, (LPVOID *)&pHTMLWnd))) { if(SUCCEEDED(pHTMLWnd->get_document( &pFrameDoc))) { BSTR bstr=NULL; HRESULT hr=pFrameDoc->get_URL(&bstr); ASSERT(SUCCEEDED(hr)); CString str= bstr; SysFreeString(bstr); pFrameDoc->Release(); pFrameDoc=NULL; } pHTMLWnd->Release(); pHTMLWnd=NULL; } } } } } } } catch(...) { }; try { if(pDoc != NULL) pDoc->Release(); if(pFramesCollection != NULL) pFramesCollection->Release(); } catch(...) { };

        H Offline
        H Offline
        Hans Ruck
        wrote on last edited by
        #3

        It works perfect for me. What's wrong?


        "tous les sifflets des trains, toutes les sirènes des bateaux   m'ont chanté cent fois la chanson de l'Eldorado" rechi+

        T 1 Reply Last reply
        0
        • H Hans Ruck

          It works perfect for me. What's wrong?


          "tous les sifflets des trains, toutes les sirènes des bateaux   m'ont chanté cent fois la chanson de l'Eldorado" rechi+

          T Offline
          T Offline
          Tcpip2005
          wrote on last edited by
          #4

          which site did you use for a test? I would like to have a try. Thank u.

          H 1 Reply Last reply
          0
          • T Tcpip2005

            which site did you use for a test? I would like to have a try. Thank u.

            H Offline
            H Offline
            Hans Ruck
            wrote on last edited by
            #5

            Here: http://www.jalfrezi.com/x_frame.htm[^]


            "tous les sifflets des trains, toutes les sirènes des bateaux   m'ont chanté cent fois la chanson de l'Eldorado" rechi+

            1 Reply Last reply
            0
            • T Tcpip2005

              I tried as bellow,but I think it doesn't work correctly. Who knows how?? Thank you very much. IHTMLDocument2 * pDoc = NULL; IHTMLWindow2 *pHTMLWnd = NULL; IHTMLDocument2 * pFrameDoc=NULL; IHTMLFramesCollection2 *pFramesCollection=NULL; LPDISPATCH lpDispatch; long p; VARIANT varindex,varresult; varresult.vt=VT_DISPATCH; varindex.vt = VT_I4; try { pDoc = (IHTMLDocument2*)(GetHtmlDocument()); if(pDoc!=NULL) { pDoc->get_frames(&pFramesCollection); if(pFramesCollection!=NULL) { pFramesCollection->get_length(&p); if(p>0) { for(int i=0; iitem(&varindex, &varresult) ==S_OK) { lpDispatch=(LPDISPATCH)varresult.ppdispVal; if (SUCCEEDED(lpDispatch->QueryInterface(IID_IHTMLWindow2, (LPVOID *)&pHTMLWnd))) { if(SUCCEEDED(pHTMLWnd->get_document( &pFrameDoc))) { BSTR bstr=NULL; HRESULT hr=pFrameDoc->get_URL(&bstr); ASSERT(SUCCEEDED(hr)); CString str= bstr; SysFreeString(bstr); pFrameDoc->Release(); pFrameDoc=NULL; } pHTMLWnd->Release(); pHTMLWnd=NULL; } } } } } } } catch(...) { }; try { if(pDoc != NULL) pDoc->Release(); if(pFramesCollection != NULL) pFramesCollection->Release(); } catch(...) { };

              R Offline
              R Offline
              Ralf Martin Hansen
              wrote on last edited by
              #6

              I am still using this 2024. Your example is useful and helped me through the jungle. i is an integer not a string. varindex.lval = i; Than things are working, already. Maybe someone else can use.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups