rvico TRichView Reference | TRichView

TCustomRichView.GetWordAt, GetWordAtA, GetWordAtW

Top  Previous  Next

Returns word at the specified coordinates

procedure GetWordAt(X,Y: Integer;

  var RVData: TCustomRVFormattedDatavar ItemNo: Integer; 

  var Word: TRVUnicodeString); overload;

function GetWordAtA(X,Y: Integer): TRVAnsiString;

function GetWordAtW(X,Y: Integer): TRVUnicodeString

function GetWordAt(X,Y: Integer): String;

(changed in version 18)

Input parameters

(X,Y) – client coordinates (coordinates relative to the top left corner of RichView window).

Output parameters

Word (or returned value for the simplified versions) receives word (if it is a text item), or name of non-text item. See the Unicode note below. "Word" is defined as a part of string between delimiters. Delimiters are listed in Delimiters property.

ItemNo receives index of item at (X,Y), or -1 if there is no item at this point. This is an index of item in RVData object (it may be the main document, cell, or cell inplace editor).


unicode Unicode notes:

Internally, all text is stored as Unicode. GetWordAtA (and GetWordAt in non-Unicode versions of Delphi) converts it to ANSI using Style.DefCodePage.


For example, you can use this method inside OnRVMouseDown and OnRVMouseUp.

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


Example: displaying the clicked words (only text items!) in Label1.

We cannot use simplified version of GetWordAt because we cannot know if the returned text is for text item.

uses CRVFData;


procedure TForm1.RichView1RVMouseUp(Sender: TCustomRichView;

  Button: TMouseButton; Shift: TShiftState; ItemNo, X, Y: Integer);


  LItemNo: Integer;

  LRVData: TCustomRVFormattedData;

  LWord: TRVUnicodeString;


  ItemNo<0 then

    exit; // we already know that the mouse is not above item

  Sender.GetWordAt(X,Y, LRVData, LItemNo, LWord);

  if LItemNo<0 then


  if LRVData.GetItemStyle(LItemNo)>=0 then // text item?

    Label1.Caption := LWord;



See also events:





See also properties:


See also methods:


TRichView © trichview.com