Share via


ITextRangeProvider::ExpandToEnclosingUnit Method

Expands the text range to the specified text unit.

Syntax

HRESULT ExpandToEnclosingUnit(      
    TextUnit unit
);

Parameters

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

If the range is already an exact quantity of the specified units then it remains unchanged.

If the starting endpoint is not at a text unit boundary, it is moved backward until it is at a text unit boundary. Subsequently, if the ending endpoint is not at a text unit boundary, or if it is at the same text unit boundary as the starting endpoint, the ending endpoint is moved forward until it is at a text unit boundary.

Note   This is necessary as it is common for a screen reader to read out a full word, sentence, or entire paragraph at the insertion point or any virtual cursor position.

ITextRangeProvider::ExpandToEnclosingUnit respects both hidden and visible text.

ITextRangeProvider::ExpandToEnclosingUnit defaults to the next largest text unit supported if the given text unit is not supported by the control.

The order, from smallest unit to largest, is listed here.

  • Character
  • Format
  • Word
  • Line
  • Paragraph
  • Page
  • Document

See Also

UI Automation Providers Overview, ITextProvider