Discussion:
How to extract a line from a memo object?
(too old to reply)
SnookyT
2022-09-04 16:37:01 UTC
Permalink
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
JJ
2022-09-05 00:44:56 UTC
Permalink
Post by SnookyT
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.
Skybuck Flying
2022-09-10 00:00:18 UTC
Permalink
Post by SnookyT
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
This is one of those shitty Delphi VCL shortcomings, hard to do/use. There will be other issues like scrolling etc.

Consider using another component which might be a bit better like TListBox.

Some kind of control that isolates the lines from each other and returns an index for what was selected.

Unless you really want to use a TMemo, what is it that you want to do ?

Bye for now,
Skybuck.

Loading...