home *** CD-ROM | disk | FTP | other *** search
/ Delphi 4 Bible / Delphi_4_Bible_Tom_Swan_IDG_Books_1998.iso / source / Animator / Main.pas < prev   
Pascal/Delphi Source File  |  1998-03-11  |  2KB  |  91 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     Animate1: TAnimate;
  12.     RadioGroup1: TRadioGroup;
  13.     GoBitBtn: TBitBtn;
  14.     StopBitBtn: TBitBtn;
  15.     BitBtn1: TBitBtn;
  16.     StatusText: TStaticText;
  17.     Label1: TLabel;
  18.     procedure GoBitBtnClick(Sender: TObject);
  19.     procedure StopBitBtnClick(Sender: TObject);
  20.   private
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25.  
  26. var
  27.   MainForm: TMainForm;
  28.  
  29. implementation
  30.  
  31. {$R *.DFM}
  32.  
  33. { Define array types for easier assignments of the
  34.   Animate object's CommonAvi property, and also the
  35.   StatusText object that shows which animation is running. }
  36. type
  37.   aviKindArray = array[0 .. 7] of TCommonAvi;
  38.   aviStringArray = array[0 .. 7] of String;
  39.  
  40. { Define constant arrays containing the TCommonAvi values
  41.   in the same order they appear in the RadioGroup object,
  42.   and also strings for displaying in the StatusText object
  43.   that shows which animation is running. }
  44. const
  45.  
  46.   aviKinds: aviKindArray =
  47.     (aviCopyFile,
  48.      aviCopyFiles,
  49.      aviDeleteFile,
  50.      aviEmptyRecycle,
  51.      aviFindComputer,
  52.      aviFindFile,
  53.      aviFindFolder,
  54.      aviRecycleFile);
  55.  
  56.   aviStrings: aviStringArray =
  57.     ('aviCopyFile',
  58.      'aviCopyFiles',
  59.      'aviDeleteFile',
  60.      'aviEmptyRecycle',
  61.      'aviFindComputer',
  62.      'aviFindFile',
  63.      'aviFindFolder',
  64.      'aviRecycleFile');
  65.  
  66. { Start selected animation. This event handler is assigned
  67.   to the OnClick event for both the Go button and the
  68.   RadioGroup1. Clicking Go or clicking a radio button starts
  69.   the animation immediately. }
  70. procedure TMainForm.GoBitBtnClick(Sender: TObject);
  71. var
  72.   AnimIndex: Integer;  // Index of selected animation
  73. begin
  74.   AnimIndex := RadioGroup1.ItemIndex;
  75.   with Animate1 do
  76.   begin
  77.     StatusText.Caption := aviStrings[AnimIndex];
  78.     CommonAVI := aviKinds[AnimIndex];
  79.     Play(1, FrameCount, 0);  // Start the animation
  80.   end;
  81. end;
  82.  
  83. { Halt the animation when user clicks the Stop button. }
  84. procedure TMainForm.StopBitBtnClick(Sender: TObject);
  85. begin
  86.   Animate1.Stop;
  87.   StatusText.Caption := '(stopped)';
  88. end;
  89.  
  90. end.
  91.