IHTMLElement -> IAccessible

2019-07-23 15:50发布

问题:

How to get IAccessible from IHTMLElement?

I have receive "Interface is not support" error.

回答1:

Not all HTML elements are accessible. See Accessible HTML Elements (there's also a list of accessible elements below). You might have hit an element that is not meant to be accessible.



回答2:

Use IServiceProvider::QueryService - full details at this article.

Basic idea is that QueryService is like a less strict version of QI: QI requires that all the interfaces are part of the same COM object and uphold certain COM guarantees (shared IUnknown, reflexitivity and transitivity). But QueryService can be used to allow access to related interfaces on separate objects. IE happens to use it a fair bit. To use it, QI the IHTMLElement to IServiceProvider, then use the QueryService method to ask for an IAccessible.