Find the position of the text cursor in a memo control #125

To determine the position of the cursor in a memo you should use messages, like in the example below.

var
  Row, Col: Integer; 
begin
  Row := SendMessage(Memo1.Handle, EM_LINEFROMCHAR, Memo1.SelStart, 0); 
  Col := Memo1.SelStart - SendMessage(Memo1.Handle, EM_LINEINDEX, Row, 0);
  Label1.caption := 'Row= ' + IntToStr(Row+1) + ' Col= ' + IntToStr(Col+1);
end;
The MemoCursorPos routine from the DelphiDabbler Code Snippets Database uses the code presented in this tip.
Author: Shlomo Abuisak
Contributor: Shlomo Abuisak
Added: 2009/11/05
Last updated: 2013/10/12