Access the current row/column of a TMemo (Views: 3)
Problem/Question/Abstract: 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. 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; |