IUIAutomationTextRange3::GetEnclosingElementBuildCache method (uiautomationclient.h)

Gets the enclosing element and supplied properties and patterns for an element in a text range in a single cross-process call. This is equivalent to calling GetEnclosingElement, but adds the standard build cache pattern.


HRESULT GetEnclosingElementBuildCache(
  [in]          IUIAutomationCacheRequest *cacheRequest,
  [out, retval] IUIAutomationElement      **enclosingElement


[in] cacheRequest

An IUIAutomationCacheRequest specifying the properties and control patterns to be cached.

[out, retval] enclosingElement

Returns the enclosing element (and properties/patterns) of the text range if it meets the criteria of the supplied cacheRequest.

Return value

Returns S_OK if successful, otherwise an HRESULT error code.


Following the design of GetEnclosingElement:

  • Gets the all-inclusive, innermost enclosing element of a text range and the supplied properties of the element.
As a result of a successful call, UI Automation clients are able call "Cached" APIs of IUIAutomationElement that are provided in the cacheRequest, for example, IUIAutomationElement::GetCachedPropertyValue.


Minimum supported client Windows 10, version 1703 [desktop apps only]
Minimum supported server None supported
Target Platform Windows
Header uiautomationclient.h (include UIAutomation.h)

See also


UI Automation Support for Textual Content