Export (0) Print
Expand All

IUIAutomationTextRange::ExpandToEnclosingUnit Method

Expands the text range to the specified text unit.

Syntax


HRESULT ExpandToEnclosingUnit(          TextUnit textUnit
);

Parameters

textUnit
[in] A value from the TextUnit enumerated type specifying the text unit, such as line or paragraph.

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, it remains unchanged.

The following steps happen in the background so that the IUIAutomationTextRange::Move method can run successfully.

  1. The text range is normalized; that is, the text range is collapsed to a degenerate (empty) range at the start endpoint, which makes the end endpoint superfluous. This step is necessary to remove ambiguity in situations where a text range spans unit boundaries; for example, "{The U}RL http://www.microsoft.com is embedded in text" where "{" and "}" are the text range endpoints.
  2. The resulting range is moved backward in the DocumentRange to the beginning of the requested unit boundary.
  3. The range is moved forward or backward in the DocumentRange by the requested number of unit boundaries.
  4. The range is then expanded from a degenerate range state by moving the end endpoint by one requested unit boundary.

Community Additions

Show:
© 2014 Microsoft