Here's the code in the thread:
procedure TAnimation.Execute;
begin
Synchronize(StartMoving)
end;
Constructor TAnimation.Create(Image: TImage; Steps, OrigineLeft, OrigineTop, FinalLeft, FinalTop: Integer);
Begin
FreeOnTerminate := True;
inherited Create(False);
TheImage:= Image;
TheStep := Steps;
TheLeft1:= OrigineLeft;
TheTop1:= Originetop;
TheLeft2 := FinalLeft;
TheTop2:= FinalTop;
End;
Procedure TAnimation.StartMoving;
var x, y: Integer;
begin
TheImage.Visible:=True;
If TheStep=0 then TheStep:=1;
For x:=1 To TheStep Do
Begin
TheImage.Visible:=False;
TheImage.Left:=TheLeft1+(x*(TheLeft2-TheLeft1) div x);
TheImage.Top:=TheTop1+(x*(TheTop2-TheTop1) div x);
TheImage.Visible:=True;
Sleep(50);
End;
End;
And Here's where I create the thread in the main code:
i:=Max(abs(TheImage.Left-370) div 30,abs(TheImage.Top-150) div 30);
TheThreadAnimation:=TAnimation.Create(TheImage, i, 370, 150, TheImage.Left, TheImage.Top);
TheThreadAnimation.Priority:= tpLower;
Thanks.