Recent

Author Topic: Lazarus - TGifAnim.  (Read 1314 times)

seghele0

  • Full Member
  • ***
  • Posts: 137
Lazarus - TGifAnim.
« on: January 12, 2022, 10:22:35 pm »
I'm using the 'Wile64' component = TGifAnim.
How can I make the 'GifAnim' disappear after 5 seconds?
 ::)
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5.   Classes, SysUtils, Forms, Controls, Graphics,
  6.   Dialogs, ExtCtrls, Buttons, GifAnim;
  7. type
  8.   TForm1 = class(TForm)
  9.     GifAnim1: TGifAnim;
  10.     SpeedButton1: TSpeedButton;
  11.     procedure SpeedButton1Click(Sender: TObject);
  12.   private
  13.   public
  14.   end;
  15. var
  16.   Form1: TForm1;
  17.  
  18. implementation
  19. {$R *.lfm}
  20.  
  21. procedure TForm1.SpeedButton1Click(Sender: TObject);
  22. begin
  23.   GifAnim1.Animate:= True;
  24.   GifAnim1.FileName:= 'test1.gif';
  25. end;
  26.  
  27. end.                          

speter

  • Sr. Member
  • ****
  • Posts: 271
Re: Lazarus - TGifAnim.
« Reply #1 on: January 13, 2022, 12:51:30 am »
In addition to jamie's comments... set the image's visible property to false.
Code: Pascal  [Select][+][-]
  1. GifAnim1.visible := false;

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Laz 2.2.0 / FPC 3.2.2 / Windows 11 (64bit)

seghele0

  • Full Member
  • ***
  • Posts: 137
Re: Lazarus - TGifAnim.
« Reply #2 on: January 13, 2022, 05:21:01 pm »
After a lot of searching and trying again ( %)), I probably found a solution.

Can my code be made even more efficient?
Thanks in advance.
 ;)
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5.   Classes, SysUtils, Forms, Controls, Graphics,
  6.   Dialogs, ExtCtrls, Buttons, StdCtrls,
  7.   GifAnim;
  8. type
  9.  
  10.   TForm1 = class(TForm)
  11.     GifAnim1: TGifAnim;
  12.     LblCountdown: TLabel;
  13.     PanelGIF: TPanel;
  14.     SpeedButton1: TSpeedButton;
  15.     Timer1: TTimer;
  16.  
  17.     procedure SpeedButton1Click(Sender: TObject);
  18.     procedure Timer1Timer(Sender: TObject);
  19.  
  20.   private
  21.        VARstart: integer;
  22.  
  23.   public
  24.     //
  25.   end;
  26. var
  27.   Form1: TForm1;
  28.  
  29. implementation
  30. {$R *.lfm}
  31. procedure TForm1.SpeedButton1Click(Sender: TObject);
  32. begin
  33.   PanelGIF.Visible:= True;
  34.   GifAnim1.Animate:= True;
  35.   GifAnim1.FileName:= 'test1.gif';
  36.   Timer1.Enabled := True;
  37.   Timer1.Interval := 1000;
  38.   LblCountdown.Caption := '';
  39.   VARstart := 5;
  40. end;
  41.  
  42. procedure TForm1.Timer1Timer(Sender: TObject);
  43. begin
  44.   LblCountdown.Caption := Format('%d',[VARstart]);
  45.   Dec(VARstart);
  46.   if (VARstart < 0) then
  47.   begin
  48.     Timer1.Enabled := False;
  49.     LblCountdown.Caption := 'Finished';
  50.     PanelGIF.Visible:= False;
  51.   end;
  52. end;
  53. end.              

 

TinyPortal © 2005-2018