FMX.Memo.TCustomMemo.TextPosToPos

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function TextPosToPos(const APos: Integer): TCaretPosition;

C++

Fmx::Text::TCaretPosition __fastcall TextPosToPos(const int APos);

Properties

Type Visibility Source Unit Parent
function public
FMX.Memo.pas
FMX.Memo.hpp
FMX.Memo TCustomMemo

Description

Converts APos into a Line/Pos coordinate in the memo control.

TextPosToPos returns the TCaretPosition format position of a character indicated by APos. TextPosToPos calculates the TCaretPosition.Line line number and TCaretPosition.Pos horizontal shifting, corresponding to the APos character count coordinate of a character in the text of the memo control.

Keep in mind that APos counts 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:

  OldPosition.Line := 1;           //Zero-based
  OldPosition.Pos := 2;            //Zero-based
  NewPosition := TextPosToPos(PosToTextPos(OldPosition) + 2);

sets the NewPosition.Line to 1 and NewPosition.Pos to 4.

TextPosToPos internally calls Model.TextPosToPos.

See Also