From RAD Studio API Documentation
Jump to: navigation, search


function PosToTextPos(const APostion: TCaretPosition): Integer;


int __fastcall PosToTextPos(const Fmx::Text::TCaretPosition &APostion);


Type Visibility Source Unit Parent
function public
FMX.Memo TCustomMemo


Converts a Line/Pos coordinate of a character into a number of this character in the text of the memo.

PosToTextPos returns an integer an integer representing a position of the character specified by APosition in the memo control. The APosition position is specified in the TCaretPosition format which uses the Line number and Pos horizontal shifting of the character in the memo control. Keep in mind that PosToTextPos calculates the character number counting end-of-line characters.

For example, if the first line of a memo's text contains 'Hello' and the second line contains 'Goodbye', then the following code:

  MyPosition.Line := 1;           //Zero-based
  MyPosition.Pos := 1;            //Zero-based
  MyString := Copy(Text, PosToTextPos(MyPosition) + 1, 3);

sets MyString to 'odb', which are the three characters starting from the third character of the second line.

PosToTextPos internally calls Model.PosToTextPos.

See Also