Bonjour,
Je suis en train de jouer avec les animations en FMX sur Delphi 10.4.2.
J'ai le code suivant qui déclanche une animation qui se détruit à la fin.
Ce code fonctionne très bien.
J'ai voulu simplifié l'écriture en utilisant une procédure anonyme, mais je n'y arrive pas.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 procedure TForm4.EndAnim(Sender: TObject); begin TThread.ForceQueue(nil, procedure begin TBitmapListAnimation(Sender).Parent.Free; end); end; procedure TForm4.Button1Click(Sender: TObject); var rec: TRectangle; anim: TBitmapListAnimation; begin // ... anim.OnFinish := EndAnim; anim.Enabled := True; end;
Voici le code modifié :
J'obtiens alors l'erreur suivante : "[dcc64 Erreur] Main.pas(68): E2010 Types incompatibles : 'TNotifyEvent' et 'Procedure'".
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 procedure TForm4.Button1Click(Sender: TObject); var rec: TRectangle; anim: TBitmapListAnimation; begin // ... anim.OnFinish := procedure(Sender: TObject) begin TThread.ForceQueue(nil, procedure begin TBitmapListAnimation(Sender).Parent.Free; end); end; anim.Enabled := True; end;
Savez-vous comment je dois m'y prendre ?
Partager