The following code reads and writes the cursor's position as row and column; counting starts at 0.
(To scroll to the cursor position, also read this tip:
Have a TMemo/ TRichEdit scroll to the cursor position.)
procedure GetMemoRowCol (M : TMemo; var Row, Col : LongInt);
begin
Row := SendMessage(M.Handle, EM_LINEFROMCHAR, M.SelStart, 0);
Col := M.SelStart-SendMessage(M.Handle, EM_LINEINDEX, Row, 0);
end;
procedure SetMemoRowCol(M : TMemo; Row, Col : Integer);
begin
M.SelStart := SendMessage(M.Handle, EM_LINEINDEX, Row, 0)
+ Col;
end;