Reputation: 5037
what i am trying to do right now is to create a scroling credit text using the TMemo component and TTimer
procedure TAboutBox.Timer1Timer(Sender: TObject);
begin
Memo1.ScrollBy(0,-1);
end;
the Tmemo lines contain the text of the credit, something like :
Thankyou to :
Junifer lamda
Exemple user 2
Coder Monalisa
etc etc
Everything work as expected, i've set the timer.interval to 1ms , the text scroll smoothly but it displays only the 3 first lines then it displays a blank space, unless i click and drag manually using the mouse inside the memo, then it displays some lines then it disappears again when i release.
I tried with both TRichedit and TListBox but the problem persist. How could this be ?
Upvotes: 3
Views: 1654
Reputation: 612993
It seems to me that ScrollBy
is not designed to do what you desire. What's more I don't think that TMemo
is necessary either.
I'd probably do this with a label and move it on the timer event. Like this:
procedure TScrollingTextForm.FormCreate(Sender: TObject);
begin
Label1.Caption :=
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do '+
'eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad '+
'minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip '+
'ex ea commodo consequat. Duis aute irure dolor in reprehenderit in '+
'voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur '+
'sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt '+
'mollit anim id est laborum.';
Label1.Top := ClientHeight;
end;
procedure TScrollingTextForm.Timer1Timer(Sender: TObject);
begin
Label1.Top := Label1.Top - 1;
end;
I found that I needed to make the form double buffered (DoubleBuffered := True
) to avoid flicker when scrolling.
Upvotes: 4