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. IID_IHTMLElement Failing

IID_IHTMLElement Failing

Scheduled Pinned Locked Moved C / C++ / MFC
8 Posts 4 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.
  • A Offline
    A Offline
    Abhi Lahare
    wrote on last edited by
    #1

    Hi, I am trying to get IID_IHTMLElement but its failing, in few cases. The GetlastError function returns 0 for these cases. I am using following function call to achive this, IHTMLElement * pElement = NULL; IHTMLDocument2 * pHTMLDoc = NULL; HRESULT hr; IServiceProvider * pSP = NULL; hr = pAccWindow->QueryInterface(IID_IServiceProvider, (void **)&pSP); hr = pSP->QueryService(IID_IHTMLElement, IID_IHTMLElement, (void **)&pElement); I do not get any exception, bur I getting pElement as NULL. I got these failure when I press the Browser BACK button in MSIE 6.0. Any pointer will be helpful, Thanks in Advance ARLahare

    L M S 3 Replies Last reply
    0
    • A Abhi Lahare

      Hi, I am trying to get IID_IHTMLElement but its failing, in few cases. The GetlastError function returns 0 for these cases. I am using following function call to achive this, IHTMLElement * pElement = NULL; IHTMLDocument2 * pHTMLDoc = NULL; HRESULT hr; IServiceProvider * pSP = NULL; hr = pAccWindow->QueryInterface(IID_IServiceProvider, (void **)&pSP); hr = pSP->QueryService(IID_IHTMLElement, IID_IHTMLElement, (void **)&pElement); I do not get any exception, bur I getting pElement as NULL. I got these failure when I press the Browser BACK button in MSIE 6.0. Any pointer will be helpful, Thanks in Advance ARLahare

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Abhi Lahare wrote:

      The GetlastError function returns 0 for these cases.

      You need to diagnose the HRESULT

      led mike

      A 1 Reply Last reply
      0
      • A Abhi Lahare

        Hi, I am trying to get IID_IHTMLElement but its failing, in few cases. The GetlastError function returns 0 for these cases. I am using following function call to achive this, IHTMLElement * pElement = NULL; IHTMLDocument2 * pHTMLDoc = NULL; HRESULT hr; IServiceProvider * pSP = NULL; hr = pAccWindow->QueryInterface(IID_IServiceProvider, (void **)&pSP); hr = pSP->QueryService(IID_IHTMLElement, IID_IHTMLElement, (void **)&pElement); I do not get any exception, bur I getting pElement as NULL. I got these failure when I press the Browser BACK button in MSIE 6.0. Any pointer will be helpful, Thanks in Advance ARLahare

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        Without knowing anything about this, I did a quick SDK search. This sample code (and similar code found on Google) seems to be common -

        // from "About Active Accessibility Support" in the PSDK

        HRESULT hr;
        IHTMLWindow2 * pWindow;
        IHTMLElement * pElement;
        hr = pSP->QueryService(IID_IHTMLWindow2, IID_IHTMLWindow2,
        (void **)&pWindow);
        if (FAILED(hr))
        hr = pSP->QueryService(IID_IHTMLElement, IID_IHTMLElement,
        (void **)&pElement);

        // Release the Service Provider interface pointer.
        pSP->Release();

        if (SUCCEEDED(hr))
        {
        // Either a window or an element pointer was returned.
        assert( pWindow || pElement);
        ....
        code here...
        // Release the pointers.
        if (pElement)
        pElement->Release();
        if (pWindow)
        pWindow->Release();
        }

        Maybe that helps? Mark

        "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

        1 Reply Last reply
        0
        • A Abhi Lahare

          Hi, I am trying to get IID_IHTMLElement but its failing, in few cases. The GetlastError function returns 0 for these cases. I am using following function call to achive this, IHTMLElement * pElement = NULL; IHTMLDocument2 * pHTMLDoc = NULL; HRESULT hr; IServiceProvider * pSP = NULL; hr = pAccWindow->QueryInterface(IID_IServiceProvider, (void **)&pSP); hr = pSP->QueryService(IID_IHTMLElement, IID_IHTMLElement, (void **)&pElement); I do not get any exception, bur I getting pElement as NULL. I got these failure when I press the Browser BACK button in MSIE 6.0. Any pointer will be helpful, Thanks in Advance ARLahare

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          From my experience the IHTMLElement interface is not accessed via IServiceProvider but simply via QueryInterface on the element in question. GetLastError is not used for error handling in COM: COM is designed with remote access in mind and the GetLastError mechanism is thread specific. In your code what is pAccWindow?

          Steve

          A 1 Reply Last reply
          0
          • S Stephen Hewitt

            From my experience the IHTMLElement interface is not accessed via IServiceProvider but simply via QueryInterface on the element in question. GetLastError is not used for error handling in COM: COM is designed with remote access in mind and the GetLastError mechanism is thread specific. In your code what is pAccWindow?

            Steve

            A Offline
            A Offline
            Abhi Lahare
            wrote on last edited by
            #5

            Thanks Stephen, I have seen code samples where IServiceProvider is used to accesses IHTMLElement and its working in my code for other cases. pAccWindow is the IAccessible pointer. Thanks for your help ARLahare

            1 Reply Last reply
            0
            • L led mike

              Abhi Lahare wrote:

              The GetlastError function returns 0 for these cases.

              You need to diagnose the HRESULT

              led mike

              A Offline
              A Offline
              Abhi Lahare
              wrote on last edited by
              #6

              Return value is E_INVALIDARG but not sure what is wrong with input parameter. Regards ARLahare

              M 1 Reply Last reply
              0
              • A Abhi Lahare

                Return value is E_INVALIDARG but not sure what is wrong with input parameter. Regards ARLahare

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                According to the docs, the object "can be an element or a window". Have you tried querying for IID_IHTMLWindow2 first as documented? Mark

                "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

                A 1 Reply Last reply
                0
                • M Mark Salsbery

                  According to the docs, the object "can be an element or a window". Have you tried querying for IID_IHTMLWindow2 first as documented? Mark

                  "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

                  A Offline
                  A Offline
                  Abhi Lahare
                  wrote on last edited by
                  #8

                  yes

                  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