Find the position of the text cursor in a memo control
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 Code Snippets Database uses the code presented in this tip.
| Author: | Shlomo Abuisak |
|---|---|
| Added: | 2009-11-05 |
| Last updated: | 2010-03-06 |
