Board index » delphi » TMemo: Which lines am I on?

TMemo: Which lines am I on?

TMemo: Which line am I on?

Using a popup menu, I want to add text to a line in a TMemo. (I'm
actually adding html code.) I could do this by typing:

-------------------------------------------------------
Memo1.Lines[0] := Memo1.Lines[0]+'<BR>';
-------------------------------------------------------

The problem is that the user may not actually be on line #1.

For fun I have also tried:

-------------------------------------------------------
procedure TForm1.LineBreakbr1Click(Sender: TObject);
var
  i : integer;
begin
for i := 0 to Memo1.Lines.Count - 1 do
Memo1.Lines[i] := Memo1.Lines[i]+'<BR>';
end;
-------------------------------------------------------

But of course this adds '<BR>' to the end of every line. Is there a way
of reading JUST the line the user is presently on and setting [n] so the
text is just printed JUST on that line?

Memo1.Lines[n] := Memo1.Lines[n]+'<BR>';

Much appreciated!
Thanks
Nathalie

 

Re:TMemo: Which lines am I on?


In article <3611003B.6...@NOSPAM.ntic.qc.ca>, Nathalie

Quote
<NOSPAM.lech...@NOSPAM.ntic.qc.ca> writes:
>TMemo: Which line am I on?

LineNo{zero based} := Memo1.Perform(EM_LINEFROMCHAR, -1, 0);

Returns the line the caret (or the start of the selection)  is on.

Alan Lloyd
alangll...@aol.com

Other Threads