I have TFrame (fraDisplay) with TTimer (timAnimateDataChange). A timer is used to control small animations. In the form containing the frame, I want to have a method that does something like this:
procedure TForm.DoStuff;
begin
DoSomeLogicStuff;
fraDisplay.AnimateResult;
WaitForAnimationToFinish;
DoSomeOtherLogicStuff;
fraDisplay.AnimateEndResult;
WaitForAnimationToFinish;
fraDisplay.Finalize;
end;
An animation is basically a TImage32 redraw synchronized by a timer. The timer will turn it off when finished, and the frame has the boolean property AnimationRunning, which will be set to false when the animation is complete.
There is no thread or anything like that to complicate or help.
The question is how to implement the WaitForAnimationToFinish method?
(Btw, this is a bad solution:
procedure TForm.WaitForAnimationToFinish;
begin
repeat
Application.ProcessMessages;
until not fraDisplay.AnimationRunning;
end;
since the timer does not work when the method starts :-()