TCustomRichView.GetSelectionBounds

<< Click to display table of contents >>

TCustomRichView.GetSelectionBounds

Returns bounds of selected part of document.

procedure GetSelectionBounds(out StartItemNo, StartItemOffs,

  EndItemNo, EndItemOffs: Integer; Normalize: Boolean);

Parameters

StartItemNo index of the first selected item.

StartItemOffs:

if the first item is a text item, then the selection start is before the StartItemOffs-th character of string (characters in strings are counted from 1, the last position (after the text item) is text length+1). The exception is empty text items formatted with style having EmptyWidth>0; for them, the position after the item is 2.

if the first item is not a text, then

if StartItemOffs=0, then the selection start is before the first item;

if StartItemOffs=1, then the selection start is after the first item.

EndItemNo index of the last selected item.

EndItemOffs:

if the last item is a text item, then the selection end is before the EndItemOffs-th character of string (characters in strings are counted from 1, the last position (after the text item) is text length+1). The exception is empty text items formatted with style having EmptyWidth>0; for them, the position after the item is 2.

if the last item is not a text, then

if EndItemOffs=0, then the selection end is before the last item

if EndItemOffs=1, then the selection end is after the last item.

Normalize:

if True, the upper bound of the selection is returned in StartItemNo:StartItemOffs, and the lower bound is in EndItemNo:EndItemOffs;

if False, bounds are returned as they were selected by user.

 

The selection is empty if

StartItemNo=-1 or

StartItemNo=EndItemNo and StartItemOffs=EndItemOffs.

 

This method must be called only when the document is formatted.

 

If you want to get selection bounds using richedit-like parameters (SelStart and SelLength), use RVGetSelection from RVLinear unit instead.

See also methods:

SetSelectionBounds.

See also:

Working with selection.