Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 1999-07

Detecting TMemo's lines property changing

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to Shane Miller: I mentioned this problem before about detecting when TMemo's lines property changed and…
Shane Miller wrote 6 lines
I mentioned this problem before about detecting when TMemo's lines property changed and someone mentioned setting TStringList's OnChanged event. The problem with that is FLines is a TStrings and you can't access the OnChange property because it's in a child class. Is there something that I'm missing?

The Flines in TMemo are declared as FStrings, but they are assigned a TMemoStrings in the Create method of TMemo. TMemostrings is a TStrings descendant that is Memo-aware; i.e. when it changes, it notifies the memo about it.

You could do it with a TStringlist and it's onchange handler, but I think it is better to make a TMemoStrings, which could be more adapted to the specifics of a memo.

Of course then you must not forget to do a

Procedure TMemo.SetStrings(Avalue : TStrings);
begin
  FLines.Assign(AVAlue);
end;

Because assigning a TStringlist to a TMemoStringlist directly wouldn't work :-)

Michael.

Reply by email

Shane Miller

I mentioned this problem before about detecting when TMemo's lines property changed and someone mentioned setting TStringList's OnChanged event. The problem with that is FLines is a TStrings and you can't access the OnChange property because it's in a child class.

Is there something that I'm missing?

Shane

Reply by email