Share via


IUIAutomationTextRange::MoveEndpointByUnit Method

Moves one endpoint of the text range the specified number of text units within the document range.

Syntax

HRESULT MoveEndpointByUnit(      
    TextPatternRangeEndpoint endpoint,
    TextUnit unit,
    int count,
    int *moved
);

Parameters

  • endpoint
    [in] A value from the TextPatternRangeEndpointEnum enumerated type specifying the endpoint (start or end) to move.
  • unit
    [in] A value from the TextUnit enumerated type specifying the textual unit for moving, such as line or paragraph.
  • count
    [in] The number of units to move. A positive count moves the endpoint forward. A negative count moves backward. A count of 0 has no effect.
  • moved
    [out, retval] The address of a variable that receives the count of units actually moved. This value can be less than the number requested if moving the endpoint runs into the beginning or end of the document.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

The endpoint is moved forward or backward, as specified, to the next available unit boundary. If the original endpoint was at the boundary of the specified text unit, the endpoint is moved to the next available text unit boundary.

Moving the endpoints of a text range

If the endpoint being moved crosses the other endpoint of the same text range, the other endpoint is also moved, resulting in a degenerate range and ensuring the correct ordering of the endpoint (that is, that the start is always less than or equal to the end).

ITextRangeProvider::MoveEndpointByUnit deprecates up to the next supported text unit 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