home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_PAS / ANIDIAL.ZIP / SIMPLE.PAS < prev   
Pascal/Delphi Source File  |  1994-01-23  |  3KB  |  84 lines

  1. {
  2.  Sample program for unit AnimateDialog written by Tim Schempp, January, 1994.
  3.  
  4.  This program demonstrates what is involved with animating a dialog box using
  5.  the unit ANIMATEDIALOG.  Although the program may look long, all of the
  6.  procedures are generally overrided in any application.  The minimum you must
  7.  add to animate Dialog Boxes is as follows:
  8.  
  9.                          1 Variables for each Animate Dialog Box.
  10.                          3 Lines of code for each Animate Dialog Box.
  11.                          2 Lines of Code for each animate View.
  12.  
  13.  The rest of this program is just usual Turbo Vision overhead.  Read the
  14.  documentation for further infomation on using the Animator, it can really
  15.  add a fun twist to an otherwise serious program.
  16.  
  17.  Please feel free to use the Dialog Box Animator in any of you programs,
  18.  and pass it on to friends.  I will get a big kick out of seeing it used in
  19.  somebody elses program.
  20. }
  21. program Simple;
  22.  
  23.   uses Objects,Views,Dialogs,App,AnimateDialog;
  24.  
  25.   type
  26.        TSimpleApp=object(TApplication)
  27.                    PSimpleDialog:PAnimateDialog;
  28.                    procedure SimpleDialog;
  29.                    procedure Idle; virtual;
  30.                   end; {object}
  31.  
  32. {******}
  33.  
  34.   procedure TSimpleApp.SimpleDialog;
  35.  
  36.   var R,Bounds:TRect;
  37.       AView:PView;
  38.       AniItem:PAniItem; {An animation entry object.}
  39.  
  40.   begin
  41.    R.Assign(20,2,60,20);
  42.    PSimpleDialog:=New(PAnimateDialog,Init(R,'Look an Animate Dialog Box!'));
  43.  
  44.    with PSimpleDialog^ do
  45.     begin
  46.      {Make A View}
  47.      R.Assign(15,13,25,15);
  48.      AView:=New(PButton,Init(R,'~O~k',cmOk,bfDefault));
  49.      Insert(AView);
  50.      {Add it to the Animation List}
  51.      GetExtent(Bounds); {<-Create a Boundry for the Animation}
  52.      Inc(Bounds.B.X,-1); Inc(Bounds.B.Y,-1);
  53.      Inc(Bounds.A.X,1);  Inc(Bounds.A.Y,1);
  54.      AniItem:=New(PAniItem,Init(AView,Bounds,AniBounceAround,11,3,1));
  55.      AniList^.Insert(AniItem);
  56.     end; {with}
  57.  
  58.    DeskTop^.ExecView(PSimpleDialog);
  59.    Dispose(PSimpleDialog,Done);
  60.    {*** !!! ***}
  61.    PSimpleDialog:=nil; {Important set the pointer to nil when the Box is
  62.                         Disposed of or the system will freeze when it tries
  63.                         to UpDate the nonexistant Dialog Box!!!}
  64.   end;
  65.  
  66. {******}
  67.  
  68.   procedure TSimpleApp.Idle;
  69.  
  70.   begin
  71.    inherited Idle;
  72.    if PSimpleDialog<>nil then PSimpleDialog^.UpDate;
  73.   end;
  74.  
  75. {******}
  76.  
  77.   var SimpleApp:TSimpleApp;
  78.  
  79.   begin
  80.    SimpleApp.Init;
  81.    SimpleApp.SimpleDialog;
  82.    SimpleApp.Run;
  83.    SimpleApp.Done;
  84.   end.