2805:Getting the Line number in a memo Field

2805:Getting the Line number in a memo Field

KEYWORDS: Line Number Memo EM_LineFromChar AREA: VCL Programming

How do you figure out what line number you are currently
on with a TMemo control?

The trick is to use the em_LineFromChar message.  Try this:

procedure TMyForm.BitBtn1Click(Sender: TObject);
var
  iLine : Integer ;
begin
   iLine := Memo1.Perform(em_LineFromChar, $FFFF, 0);
   { Note: First line is zero }
   messageDlg('Line Number: ' + IntToStr(iLine), mtInformation,
              [mbOK], 0 ) ;
end;

        TI

DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains.


Return to Complete TI List