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. Web Development
  3. hopefully simple IE control question

hopefully simple IE control question

Scheduled Pinned Locked Moved Web Development
questionhtmlhardwarehelptutorial
3 Posts 2 Posters 0 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.
  • M Offline
    M Offline
    MikeBeard
    wrote on last edited by
    #1

    I'm new to using the IE control (MSHTML) and am not sure how to do something. I know it should be possible. Here it is: If I have an object embedded in an HTML page and I display that page within the IE control, how do I get it programmatically? It has an ID and all of that. How do I get programmatic access to the tbContentElement object? Any help, tips, or pointers to articles or whatever are/will be greatly appreciated. Thanks, Mike

    H 1 Reply Last reply
    0
    • M MikeBeard

      I'm new to using the IE control (MSHTML) and am not sure how to do something. I know it should be possible. Here it is: If I have an object embedded in an HTML page and I display that page within the IE control, how do I get it programmatically? It has an ID and all of that. How do I get programmatic access to the tbContentElement object? Any help, tips, or pointers to articles or whatever are/will be greatly appreciated. Thanks, Mike

      H Offline
      H Offline
      hkulten
      wrote on last edited by
      #2

      You must use IHTMLDocument2 interface. You can find some help on msdn.microsoft.com : http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/reference.asp example of function to retrieve the value of a tag in a html page : CString YourApp::GetTagValue(LPDISPATCH lpDispatch, CString strTagId) { CString strVal = ""; IHTMLDocument2* pHTMLDocument2 = NULL; if (lpDispatch == NULL) return ""; HRESULT hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&pHTMLDocument2); lpDispatch->Release(); if (hr != S_OK) return ""; IHTMLElementCollection *pElementCollection = NULL; hr = pHTMLDocument2->get_all(&pElementCollection); if (hr != S_OK || pElementCollection == NULL) return ""; long nElt = 0; if (pElementCollection->get_length(&nElt) != S_OK) return ""; for (int i=0; iitem(varIndex, var2, &pDisp); if (hr == S_OK && pDisp != NULL) { IHTMLElement* pElem = NULL; hr = pDisp->QueryInterface(IID_IHTMLElement, (void**)&pElem); if (hr == S_OK && pElem != NULL) { BSTR bstrId = 0, bstrVal = 0; hr = pElem->get_id(&bstrId); CString strId(bstrId); strId.MakeLower(); // Oups, we find our tag !!! if (strId.Find(strTagId) != -1 && strId != "") { // Retrieve all html code pElem->get_innerHTML(&bstrVal); strVal = CString(bstrVal); } pElem->Release(); } pDisp->Release(); } } pElementCollection->Release(); return strVal; } you can use this function like this: CString strValue = GetTagValue(m_web.GetDocument(), "myid"); With a object embedded in a html page, I think you must use the IHTMLObjectElement interface instead of the IHTMLElement interface. This is not easy to play with the syntax of theses interfaces, but it works.... Good luck !!! ;)

      M 1 Reply Last reply
      0
      • H hkulten

        You must use IHTMLDocument2 interface. You can find some help on msdn.microsoft.com : http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/reference.asp example of function to retrieve the value of a tag in a html page : CString YourApp::GetTagValue(LPDISPATCH lpDispatch, CString strTagId) { CString strVal = ""; IHTMLDocument2* pHTMLDocument2 = NULL; if (lpDispatch == NULL) return ""; HRESULT hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&pHTMLDocument2); lpDispatch->Release(); if (hr != S_OK) return ""; IHTMLElementCollection *pElementCollection = NULL; hr = pHTMLDocument2->get_all(&pElementCollection); if (hr != S_OK || pElementCollection == NULL) return ""; long nElt = 0; if (pElementCollection->get_length(&nElt) != S_OK) return ""; for (int i=0; iitem(varIndex, var2, &pDisp); if (hr == S_OK && pDisp != NULL) { IHTMLElement* pElem = NULL; hr = pDisp->QueryInterface(IID_IHTMLElement, (void**)&pElem); if (hr == S_OK && pElem != NULL) { BSTR bstrId = 0, bstrVal = 0; hr = pElem->get_id(&bstrId); CString strId(bstrId); strId.MakeLower(); // Oups, we find our tag !!! if (strId.Find(strTagId) != -1 && strId != "") { // Retrieve all html code pElem->get_innerHTML(&bstrVal); strVal = CString(bstrVal); } pElem->Release(); } pDisp->Release(); } } pElementCollection->Release(); return strVal; } you can use this function like this: CString strValue = GetTagValue(m_web.GetDocument(), "myid"); With a object embedded in a html page, I think you must use the IHTMLObjectElement interface instead of the IHTMLElement interface. This is not easy to play with the syntax of theses interfaces, but it works.... Good luck !!! ;)

        M Offline
        M Offline
        MikeBeard
        wrote on last edited by
        #3

        Thanks! This will get me started.

        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