VCL Delphi

Question:
How can I determine the current line number of a TMemo?
Answer:
You can use the Windows EM_LINEFROMCHAR message to get
the current (zero based) line number (position of the
caret) of any edit control.
Example:
procedure TForm1.Button1Click(Sender: TObject);
var
LineNumber : integer;
begin
LineNumber := SendMessage(Memo1.Handle,
EM_LINEFROMCHAR,
word(-1),
0);
ShowMessage(IntToStr(LineNumber));
end;