|
TCustomRichView.GetWordAt, GetWordAtA, GetWordAtW |
Top Previous Next |
|
Returns word at the specified coordinates procedure GetWordAt(X,Y: Integer; var RVData: TCustomRVFormattedData; var ItemNo: Integer; var Word: String); overload; function GetWordAtA(X,Y: Integer): TRVAnsiString; function GetWordAtW(X,Y: Integer): TRVUnicodeString function GetWordAt(X,Y: Integer): String; 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).
GetWordAtA always returns ANSI string: ▪If the item is a non-text item, or a text item of ANSI style, the text is returned as it is. ▪If the item is a Unicode text item, the function converts Unicode text to ANSI (Unicode text is converted basing on Charset of the item text style). GetWordAtW always returns Unicode string: ▪If the item is a Unicode text item, the text is returned as it is. ▪If the item is a non-text item, or a text item of ANSI style, the function converts ANSI text to Unicode (ANSI text is converted basing on Charset of the item text style, or on RVStyle.DefCodePage for non-text items). The simplified version of GetWordAt works like GetWordAtW in Delphi/C++Builder 2009 or newer, and as GetWordAtA in the older versions of Delphi/C++Builder.
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); var LItemNo: Integer; LRVData: TCustomRVFormattedData; LWord: String; begin 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 exit; if LRVData.GetItemStyle(LItemNo)>=0 then // text item? Label1.Caption := LWord; end;
There is one more version of this method: GetWordAtR. It returns text in Word as it is, in TRVRawByteString parameter.
See also events: See also properties: See also methods: |