Don't use any Sleep
calls in the main thread, you can rotate TImage without TTimer so:
procedure TForm1.Button1Click(Sender: TObject);
var
sText: string;
begin
Button1.Enabled := False;
sText := Button1.Text;
Button1.Text := 'Wait...';
TThread.CreateAnonymousThread(procedure
begin
while Image1.RotationAngle < 360 do begin
TThread.Synchronize(nil, procedure
begin
Image1.RotationAngle := Image1.RotationAngle + 2;
end);
Sleep(10);
end;
TThread.Synchronize(nil, procedure
begin
Button1.Text := sText;
Button1.Enabled := True;
end);
end).Start;
end;
Second solution: Add Anim: TFloatAnimation
to the Form:
type
TForm1 = class(TForm)
...
public
Anim: TFloatAnimation;
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
Anim.Enabled := False;
Image1.RotationAngle := 0;
Anim.Enabled := True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Anim := TFloatAnimation.Create(Self);
Anim.Parent := Self;
Anim.Duration := 1;
Anim.StartValue := 0;
Anim.StopValue := 360;
Anim.PropertyName := 'Image1.RotationAngle';
end;
TFloatAnimation
component to adjust theRotationAngle
over time. See Using FireMonkey Animation Effects. – Remy Lebeau