community.borland.com

Article #15773: Getting the Line number in a memo Field

 Technical Information Database

TI773D.txt   Getting the Line number in a memo Field
Category   :VCL
Platform    :All
Product    :Delphi  All

Description:
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;


Reference:


7/16/98 4:33:53 PM
 

Last Modified: 01-SEP-99