home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 March / Chip_1999-03_cd.bin / zkuste / delphi / INFO / DI9806CJ.ZIP / ANIMATEU.PAS < prev    next >
Pascal/Delphi Source File  |  1998-03-22  |  2KB  |  86 lines

  1. unit animateu;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, ExtCtrls, ComCtrls, TypInfo;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     ComboBox1: TComboBox;
  13.     Label1: TLabel;
  14.     Panel1: TPanel;
  15.     Animate1: TAnimate;
  16.     procedure Timer1Timer(Sender: TObject);
  17.     procedure Button1Click(Sender: TObject);
  18.     procedure FormCreate(Sender: TObject);
  19.     procedure ComboBox1Change(Sender: TObject);
  20.   private
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25.  
  26. var
  27.   Form1: TForm1;
  28.  
  29. implementation
  30.  
  31. {$R *.DFM}
  32.  
  33. procedure TForm1.Timer1Timer(Sender: TObject);
  34. begin
  35. Animate1.Stop;
  36. Button1.Caption := '&Start';
  37. end;
  38.  
  39. procedure TForm1.Button1Click(Sender: TObject);
  40. begin
  41. if ComboBox1.Text = 'aviNone' then exit;
  42. if Button1.Caption = '&Start' then
  43.   begin
  44.     Animate1.Play(1,Animate1.FrameCount,0);
  45.     Button1.Caption := '&Stop';
  46.   end
  47. else
  48.   begin
  49.     Animate1.Stop;
  50.     Button1.Caption := '&Start';
  51.   end;
  52. end;
  53.  
  54. procedure TForm1.FormCreate(Sender: TObject);
  55. var
  56.   ca: TCommonAvi;
  57. begin
  58. //for each of the values of the TCommonAVI enumerated type
  59. for ca := low(TCommonAvi) to high(TCommonAvi) do
  60.   begin
  61.      //Get the string equivalent of the enumerated type value
  62.      ComboBox1.Items.Add(GetEnumName(TypeInfo(TCommonAvi),Ord(ca)));
  63.   end;
  64.   ComboBox1.ItemIndex := 0;
  65. end;
  66.  
  67. procedure TForm1.ComboBox1Change(Sender: TObject);
  68. var
  69.   ValueOrd: Integer;
  70. begin
  71. if Animate1.Active then
  72.   begin
  73.     Button1.Caption := '&Start';
  74.     Animate1.Stop;
  75.   end;
  76. //Get the ordinal position of the value associated
  77. //with the selected string in the ComboBox.
  78. ValueOrd := GetEnumValue(TypeInfo(TCommonAvi),
  79.                          ComboBox1.Items[ComboBox1.ItemIndex]);
  80. //Cast this ordinal value to the TCommonAVI type
  81. Animate1.CommonAVI := TCommonAVI(ValueOrd);
  82. end;
  83.  
  84.  
  85. end.
  86.