Author: Tomas Rutkauskas
I want to use a TMemo as a FIFO, and every time a new string is written to the
memo, the OnChange event will be triggered. In the OnChange event I will do my work
on the string and as the last thing make a memo.delete(0) so that the next string
in the memo will move to line 0. My question is now, is this a right thing to do? I
suppose that it will make a recursive call to the OnChange event and that I in this
way have a "system" that will empty my memo as fast as possible.
Answer:
The trick is to save, wipe, and restore the event value:
1 2 procedure TForm1.Memo1Change(Sender: TObject);
3 var4 Save: TNotifyEvent;
5 begin6 Save := Memo1.OnChange; {Save}7 Memo1.OnChange := nil; {Erase}8 Memo1.Lines.Delete(0);
9 Memo1.OnChange := Save; {Restore}10 end;