Saturday, April 11, 2009

Funny animate caption in delphi about

Drop a button (TButton named "AnimateButton"), a label (TLabel named "lblText") and an edit (TEdit named "editToAnimate") control on a form (named "AnimationForm").

Handle the button's OnClick event:

procedure TAnimationForm.AnimateButtonClick(Sender: TObject) ;
var
c, charInProcess : char;
word : string;
begin
lblText.Caption := '';

for c in editToAnimate.Text do
begin
for charInProcess in ['a' .. c] do
begin
lblText.Caption := word + charInProcess;
lblText.Refresh;
Sleep(100) ;
Application.ProcessMessages;
end;
word := word + c;
end;

lblText.Caption := word;
end;

No comments:

Post a Comment