views:

50

answers:

1

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.

+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
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
That's doubtful because internally it has to concatenate the string anyway. Moreover, the optimizer should catch this case easily.
dark_charlie