Re: How to extract a line from a memo object?

JJ <[email protected]> Mon, 5 Sep 2022 07:44:56 +0700
Newsgroups alt.comp.lang.borland-delphi
Organization A noiseless patient Spider
Message-ID <[email protected]>
On Sun, 4 Sep 2022 11:37:01 -0500, SnookyT wrote:
> I have used the following line ok
>     edtProp.Text := memo1.Lines[8];
> but how do I get the line that was clicked on instead of using 8?
> thx S

Use window messages.

offset = EM_CHARFROMPOS
         or
         EM_GETSEL

row = EM_LINEFROMCHAR + 1
col = offset - EM_LINEINDEX(EM_LINEFROMCHAR(offset)) + 1

Note: result will be incorrect if the interrested line is long enough to
wrap to another line. It doesn't matter whether word-wrap is enabled or not.
That's a flaw within the default EDIT window class handler.