Author: Tomas Rutkauskas
Access the current row/column of a TMemo
Answer:
The following code reads and writes the cursor's position as row and column;
counting starts at 0.
1 procedure GetMemoRowCol(M: TMemo; var Row, Col: LongInt);
2 begin3 Row := SendMessage(M.Handle, EM_LINEFROMCHAR, M.SelStart, 0);
4 Col := M.SelStart - SendMessage(M.Handle, EM_LINEINDEX, Row, 0);
5 end;
6 7 procedure SetMemoRowCol(M: TMemo; Row, Col: Integer);
8 begin9 M.SelStart := SendMessage(M.Handle, EM_LINEINDEX, Row, 0) + Col;
10 end;