Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi - Memo Right Click Get Line Number

How do I get the line number of a memo when I right click on it?

A ListBox has .ItemAtPos but I've not been able to find a similar function

-Brad

like image 912
Brad Avatar asked Nov 23 '25 14:11

Brad


1 Answers

In Delphi 2010, TRichEdit has an ActiveLineNo property. Not sure if it exists in Delphi 2009.

The manual way to get the line number is to send the Memo an EM_LINEFROMCHAR message with the WParam value set to -1, ie:

LineNo := SendMessage(Memo1.Handle, EM_LINEFROMCHAR, -1, 0);

Or:

LineNo := Memo1.Perform(EM_LINEFROMCHAR, -1, 0);
like image 113
Remy Lebeau Avatar answered Nov 26 '25 10:11

Remy Lebeau