I want to know how can I use a TTimer
object to do an infinite loop, that should add the letter N
on a TextBox
every second. But without freezing the application.
views:
50answers:
1
+2
A:
Add a TTimer component to your form, set its interval property to 1000 (1 sec) and handle the OnTimer event. To the code of the handler put this (assuming your textbox is named textBox1):
textBox1.Text := textBox1.Text + 'N';
dark_charlie
2010-07-30 22:43:50
It would be more efficient, both performance wise and memory wise, to use the SelText property instead of the Text property, ie: `textBox1.SelStart := textBox1.GetTextLen; textBox1.SelLength := 0; textBox1.SelText := 'N';`
Remy Lebeau - TeamB
2010-07-31 00:42:26
That's doubtful because internally it has to concatenate the string anyway. Moreover, the optimizer should catch this case easily.
dark_charlie
2010-07-31 11:38:09