Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4043626
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:09:02+00:00 2026-05-20T13:09:02+00:00

I have the following code: IAccessible *pAccessible = NULL; IServiceProvider *pServProv = NULL; AccessibleObjectFromWindow((HWND)0x0025093A,

  • 0

I have the following code:

IAccessible *pAccessible = NULL;
IServiceProvider *pServProv = NULL; 
AccessibleObjectFromWindow((HWND)0x0025093A, OBJID_CLIENT, IID_IAccessible, (void**)&pAccessible);

HRESULT hr = pAccessible->QueryInterface(IID_IServiceProvider, (void**)&pServProv);
if (SUCCEEDED(hr) && (pServProv != NULL))
{
    const GUID unused;
    ISimpleDOMDocument *pAccDoc = NULL;

    hr = pServProv->QueryService(unused, IID_ISimpleDOMDocument, (void**)&pAccDoc);

    if (SUCCEEDED(hr) && (pAccDoc != NULL))
    {
        // Success
    }
    else
    {
        // Failure
    }
}

The hard-coded HWND above is to an instance of MozillaContentWindowClass.

I can get as far as QueryService – AccessibleObjectFromWindow and QueryInterface both succeed and return non-NULL objects; however, QueryService returns ‘Invalid Parameter’. I’ve seen other suggestions, one of which is not using QueryService – just calling QueryInterface with IID_ISimpleDom* – but those calls return a ‘No Service’ error.

I’ve also seen suggestions to navigate to the Document object, and get a reference to the node from there – but I’m not quite sure how to accomplish that (I’m new to IAccessibility).

I appreciate any insight.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T13:09:03+00:00Added an answer on May 20, 2026 at 1:09 pm

    Magic GUID provided by Mozilla

    if (pAccChild)
    {
        CComQIPtr<IServiceProvider> provider = pAccChild;
        if( provider ){
           const GUID refguid = {0x0c539790, 0x12e4, 0x11cf, 0xb6, 0x61, 0x00, 0xaa, 0x00, 0x4c, 0xd6, 0xd8};
    
          CComPtr<ISimpleDOMNode> node;
          provider->QueryService(refguid, IID_ISimpleDOMNode, (void**)&node);
          CComQIPtr<ISimpleDOMDocument> ffdocument = node;
          if (node) {
            ffdocument->get_URL(&DOM_string);
            if (DOM_string != 0) { 
                addressbar = (const wchar_t *)_bstr_t(DOM_string, FALSE); 
            }
          }
    

    Now, between AccessibleObjectFromWindow and getting the provider, you may need to move around the accessible heirarchy, that can be a bit messy.

    Have a look at this Code Project – XMSAALib for suggestions.

    Here is an example of some of the tree walking covering various issues. Modified from the original to use ATL smart pointers and some bug fixes (or introduced 😉 )

    //-----------------------------------------------------------------------------
    bool CXMSAALib::EnumAccessible(IAccessible *pIAccParent, IAccessibleEnumProc& lpEnumAccessibleProc )
    {
        _ASSERTE(pIAccParent);
    
        // 2 ways to go through the children
        // * some parents will support the Enum(erator) interface where child ids may not be a contiguous sequence, and children may be returned as id or IAccessible directly
        // * others support the accChild function only where the count and ids should be contiguous.
    
        CComQIPtr<IEnumVARIANT> pEnum = pIAccParent;
        if( pEnum )
            pEnum->Reset();
    
        // get child count
        long nChildren = 0;
        if( FAILED( pIAccParent->get_accChildCount(&nChildren) ) )
            nChildren = 0;
        //TRACE(_T("nChildren=%d\n"), nChildren);
    
        bool bContinue = true;
        // skip 0 (self)
        for (long index = 1; (index <= nChildren) && bContinue; index++)
        {
            HRESULT hr =0;
            VARIANT varChildRef;
            VariantInit(&varChildRef);
            if (pEnum)
            {
                unsigned long nFetched = 0;
                hr = pEnum->Next(1, &varChildRef, &nFetched);
                //children may be returned as lVal id or IAccessible directly
                if (!SUCCEEDED(hr) || !nFetched )
                {
                    bContinue = false;
                    break;
                }
            }
            else
            {
                varChildRef.vt = VT_I4;
                varChildRef.lVal = index;
            }
    
            // IAccessible doesn't always allow indirect access to children that are also of type IAccessible
            // change the focus to the child element if we can
            VARIANT varChild;
            VariantInit(&varChild);
            CComPtr<IAccessible> pIAccChild;
            FocusOnChild( pIAccParent, varChildRef, pIAccChild, varChild );
    
            bContinue = lpEnumAccessibleProc(pIAccChild, varChild);
    
            if ( bContinue 
                && pIAccChild 
                && CHILDID_SELF == varChild.lVal )
            {
    
                bContinue = EnumAccessible(pIAccChild, lpEnumAccessibleProc);
    
            }
    
            VariantClear(&varChild);
        }
    
        return bContinue;
    }
    
    //-----------------------------------------------------------------------------
    bool CXMSAALib::EnumAccessible(HWND hwnd, IAccessibleEnumProc& lpEnumAccessibleProc) 
    {
        if (::IsWindow(hwnd))
        {
            CComPtr<IAccessible> pIAccParent;
    
            HRESULT hr = AccessibleObjectFromWindow(hwnd, OBJID_CLIENT, IID_IAccessible, (void**)&pIAccParent);
            if (SUCCEEDED(hr) && pIAccParent)
            {
                VARIANT varChild;
                VariantInit(&varChild);
                varChild.vt = VT_I4;
                varChild.lVal = CHILDID_SELF;
                if( lpEnumAccessibleProc(pIAccParent, varChild) ) {
                    EnumAccessible(pIAccParent, lpEnumAccessibleProc, nLevel+1);
                }
    
                VariantClear(&varChild);
                return true;
            }
        }
        return false;
    }
    
    //-----------------------------------------------------------------------------
    void CXMSAALib::FocusOnChild( IAccessible * pIAccParent, VARIANT &varChildRef, CComPtr<IAccessible> &pIAccChild, VARIANT &varChild ) 
    {
        // get IDispatch interface for the child
        CComPtr<IDispatch> pDisp;
        if (varChildRef.vt == VT_I4)
        {
            pIAccParent->get_accChild(varChildRef, &pDisp);
        }
        else if (varChildRef.vt == VT_DISPATCH)
        {
            pDisp = varChildRef.pdispVal;
        }
    
        // get IAccessible interface for the child
        CComQIPtr<IAccessible> pCAcc(pDisp);
    
        if (pCAcc && pCAcc != pIAccParent )
        {
            VariantInit(&varChild);
            varChild.vt = VT_I4;
            varChild.lVal = CHILDID_SELF;
            pIAccChild = pCAcc;
        }
        else
        {
            pIAccChild = pIAccParent;
            varChild = varChildRef;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From 19 Deadly Sins of Software Security ; The following code is the poster
I'm following http://ruby.railstutorial.org/chapters/following-users#code:from_users_followed_by_final and these tests fails: describe status feed do it should have
I have the following models defined in my application User Profile Address Here is
My problem is the following; I have a class that uses non-static native methods
I currently want to make my project accessible not only via back-end code (C#,
I'm creating an application that will run code in a sandboxed environment. This environment
I'm creating a multi-tenant Asp.Net MVC 3 Web app, and using EF4.1 code first
I am trying to build a self-hosted PHP site, but I am having trouble
I am developing an Android App that gets some data from a web server,
Thans for looking, I hope you could help me. Currently, I want to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.