Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to delete a line in a TMemo in its OnChange event Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
25-Jan-04
Category
Reporting /Printing
Language
Delphi 2.x
Views
144
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			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   var
4     Save: TNotifyEvent;
5   begin
6     Save := Memo1.OnChange; {Save}
7     Memo1.OnChange := nil; {Erase}
8     Memo1.Lines.Delete(0);
9     Memo1.OnChange := Save; {Restore}
10  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC