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

  1. {
  2.  Demo program for the Dialog Box Animator.
  3.  
  4.   By Tim Schempp
  5.      January, 1994
  6.      CompuSevre Id 71224,455
  7.  
  8.  This program will give you a pretty good idea of what the Dialog Animator
  9.  can do to spice up your programs.  This sample program may seem a little
  10.  long and involved, but it was necessary to fully demonstrate the unit.
  11.  program SIMPLE.PAS will give you a simpler more readable example of how to
  12.  use this unit.  Read the documentation for a full explanation of the
  13.  units features.
  14.  
  15.  Please feel free to use the Dialog Box Animator in any of you programs,
  16.  and pass it on to friends.  I will get a big kick out of seeing it used in
  17.  somebody elses program.
  18. }
  19.  
  20. program AniTest;
  21.  
  22.  uses Objects,Drivers,Views,App,Menus,Dialogs,Editors,MsgBox,AnimateDialog;
  23.  
  24.  const cmBounceBox  = 1001;
  25.        cmBounceDH   = 1002;
  26.        cmBounceDV   = 1003;
  27.        cmBounceDA   = 1004;
  28.  
  29.        cmAbout      = 1005;
  30.  
  31.        cmDataEntry  = 1006;
  32.        cmSubView    = 1007;
  33.  
  34.        cmExitNow    = 1008;
  35.        cmSlower     = 1009;
  36.  
  37.        cmWinDialog  = 1010;
  38.  
  39.        cmAniToggle  = 1011;
  40.  
  41.  type
  42.       TTestApp=object(TApplication)
  43.                 PAbout,
  44.                 PBounceBox,
  45.                 PDataEntryBox,
  46.                 PSubView,
  47.                 PWinDialog,
  48.                 PExitDialog:PAnimateDialog;
  49.  
  50.                 AnimationOff:Boolean;
  51.                 constructor Init;
  52.                 procedure HandleEvent(var Event:TEvent); virtual;
  53.                 procedure GetEvent(var Event:TEvent); virtual;
  54.                 procedure InitStatusLine; virtual;
  55.                 procedure Idle; virtual;
  56.                 procedure About;
  57.                 procedure BounceBox;
  58.                 procedure DataEntry;
  59.                 procedure SubView;
  60.                 procedure WinDialog;
  61.                 procedure MakeWindows;
  62.                 procedure ExitDialog;
  63.                end;
  64.  
  65. {******}
  66.  
  67.  constructor TTestApp.Init;
  68.  
  69.  begin
  70.   inherited Init;
  71.   AnimationOff:=False;
  72.  end;
  73.  
  74. {******}
  75.  
  76.  procedure TTestApp.HandleEvent(var Event:TEvent);
  77.  
  78.  begin
  79.   inherited HandleEvent(Event);
  80.  
  81.   case Event.What of
  82.    evCommand: case Event.Command of
  83.                cmBounceBox      :  begin BounceBox;
  84.                                          ClearEvent(Event); end;
  85.                cmAbout          :  begin About;
  86.                                          ClearEvent(Event); end;
  87.                cmDataEntry      :  begin DataEntry;
  88.                                          ClearEvent(Event); end;
  89.                cmWinDialog      :  begin WinDialog;
  90.                                          ClearEvent(Event); end;
  91.                cmExitNow        :  begin ExitDialog;
  92.                                          ClearEvent(Event); end;
  93.                cmAniToggle      :  AnimationOff:=not AnimationOff;
  94.               end; {case}
  95.   end; {case}
  96.  end;
  97.  
  98. {******}
  99.  
  100.  procedure TTestApp.GetEvent(var Event:TEvent);
  101.   var R:TRect;
  102.  begin
  103.   inherited GetEvent(Event);
  104.   case Event.What of
  105.    evCommand : case Event.Command of
  106.                 cmBounceDV  :  begin
  107.                                 with PAniItem(PBounceBox^.AniList^.At(0))^ do
  108.                                  begin
  109.                                   XStep:=0; YStep:=1;
  110.                                   Param:=AniBounceBack;
  111.                                  end; {with}
  112.                                 ClearEvent(Event);
  113.                                end;
  114.                 cmBounceDH  :  begin
  115.                                 with PAniItem(PBounceBox^.AniList^.At(0))^ do
  116.                                  begin
  117.                                   XStep:=2; YStep:=0;
  118.                                   Param:=AniBounceBack;
  119.                                  end; {with}
  120.                                 ClearEvent(Event);
  121.                                end;
  122.                 cmBounceDA  :  begin
  123.                                 with PAniItem(PBounceBox^.AniList^.At(0))^ do
  124.                                  begin
  125.                                   XStep:=2; YStep:=1;
  126.                                   Param:=AniBounceAround;
  127.                                  end; {with}
  128.                                 ClearEvent(Event);
  129.                                end;
  130.                cmSubView    :  begin SubView;
  131.                                       ClearEvent(Event); end;
  132.                cmAniToggle  :  AnimationOff:=not AnimationOff;
  133.                cmSlower     :  with PAniItem(PExitDialog^.AniList^.At(0))^ do
  134.                                 if DelayTime<=50 then Inc(DelayTime,1);
  135.                end; {case}
  136.   end; {case}
  137.  end;
  138.  
  139. {******}
  140.  
  141.   procedure TTestApp.InitStatusLine;
  142.  
  143.   var R:TRect;
  144.  
  145.   begin
  146.    GetExtent(R);
  147.    R.A.Y:=R.B.Y-1;
  148.    StatusLine:=New(PStatusLine,Init(r,
  149.                    NewStatusDef(0, $ffff,
  150.                    NewStatusKey('~Alt-X~ Exit',kbAltX,cmExitNow,
  151.                    NewStatusKey('~F2~ About',kbF2,cmAbout,
  152.                    NewStatusKey('~F3~ Bounce',kbF3,cmBounceBox,
  153.                    NewStatusKey('~F4~ Entries',kbF4,cmDataEntry,
  154.                    NewStatusKey('~F5~ Windows',kbF5,cmWinDialog,
  155.                    NewStatusKey('~F9~ Toggle Animation',kbF9,cmAniToggle,
  156.                                  nil)))))),
  157.                   nil)
  158.                 ));
  159.   end;
  160.  
  161. {******}
  162.  
  163.  procedure TTestApp.Idle;
  164.  
  165.  begin
  166.   inherited Idle;
  167.   if not AnimationOff then
  168.      begin
  169.       if PAbout<>nil then PAbout^.UpDate;
  170.       if PBounceBox<>nil then PBounceBox^.UpDate;
  171.       if PDataEntryBox<>nil then PDataEntryBox^.UpDate;
  172.       if PSubView<>nil then PSubView^.UpDate;
  173.       if PWinDialog<>nil then PWinDialog^.UpDate;
  174.       if PExitDialog<>nil then PExitDialog^.UpDate;
  175.      end; {if}
  176.  end;
  177.  
  178. {******}
  179.  
  180.  procedure TTestApp.About;
  181.  
  182.  var  R:TRect;
  183.       Boundry:TRect;
  184.       AView:PView;
  185.       AniItem:PAniItem;
  186.  
  187.  begin
  188.   R.Assign(20,2,60,20);
  189.   PAbout:=New(PAnimateDialog,Init(R,'About the animator...'));
  190.  
  191.   with PAbout^ do
  192.    begin
  193.     GetExtent(Boundry);
  194.     Inc(Boundry.B.X,-1);
  195.     Inc(Boundry.B.Y,-1);
  196.     Inc(Boundry.A.X,1);
  197.     Inc(Boundry.A.Y,1);
  198.  
  199.     R.Assign(10,1,29,2);
  200.     AView:=New(PStaticText,Init(R,'THE DIALOG ANIMATOR'));
  201.     Insert(AView);
  202.     R.Assign(10,1,29,6);
  203.     AniItem:=New(PAniItem,Init(AView,R,AniBounceBack,15,0,1));
  204.     AniList^.Insert(AniItem);
  205.  
  206.     R.Assign(1,7,15,8);
  207.     AView:=New(PStaticText,Init(R,'By Tim Schempp'));
  208.     Insert(AView);
  209.     R.Assign(Boundry.A.X,7,Boundry.B.X,8);
  210.     AniItem:=New(PAniItem,Init(AView,R,AniBounceBack,10,1,0));
  211.     AniList^.Insert(AniItem);
  212.  
  213.     R.Assign(10,9,30,15);
  214.     AView:=New(PStaticText,Init(R,''));
  215.     AView^.Options:=AView^.Options or ofFramed;
  216.     Insert(AView);
  217.  
  218.     R.Assign(10,9,23,11);
  219.     AView:=New(PStaticText,Init(R,'CompuServe ID'+Chr(13)+'   71224,455'));
  220.     Insert(AView);
  221.     R.Assign(10,9,30,15);
  222.     AniItem:=New(PAniItem,Init(AView,R,AniBounceAround,15,1,1));
  223.     AniList^.Insert(AniItem);
  224.  
  225.     R.Assign(Boundry.B.X-13,16,Boundry.B.X,17);
  226.     AView:=New(PStaticText,Init(R,'January, 1994'));
  227.     Insert(AView);
  228.     R.Assign(Boundry.A.X,16,Boundry.B.X,17);
  229.     AniItem:=New(PAniItem,Init(AView,R,AniBounceBack,15,-1,0));
  230.     AniList^.Insert(AniItem);
  231.  
  232.     R.Assign(25,15,35,17);
  233.     AView:=New(PButton,Init(R,'~O~k',cmOk,bfDefault));
  234.     Insert(AView);
  235.     AniItem:=New(PAniItem,Init(AView,Boundry,AniBounceAround,11,-3,-1));
  236.     AniList^.Insert(AniItem);
  237.    end; {with}
  238.  
  239.   DeskTop^.ExecView(PAbout);
  240.   Dispose(PAbout,Done);
  241.   PAbout:=nil;   {Don't forget to do this!!!}
  242.  
  243.   R.Assign(20,3,60,17);
  244.   PAbout:=New(PAnimateDialog,Init(R,'Please Note'));
  245.  
  246.   with PAbout^ do
  247.    begin
  248.     GetExtent(Boundry);
  249.     Inc(Boundry.B.X,-1);
  250.     Inc(Boundry.B.Y,-1);
  251.     Inc(Boundry.A.X,1);
  252.     Inc(Boundry.A.Y,1);
  253.  
  254.     R.Assign(5,1,35,2);
  255.     AView:=New(PStaticText,Init(R,'If you like this program and'));
  256.     Insert(AView);
  257.     R.Assign(5,1,35,11);
  258.     AniItem:=New(PAniItem,Init(AView,R,AniNone,25,0,1));
  259.     AniList^.Insert(AniItem);
  260.  
  261.     R.Assign(5,2,35,3);
  262.     AView:=New(PStaticText,Init(R,'found it useful'));
  263.     Insert(AView);
  264.     R.Assign(5,1,35,11);
  265.     AniItem:=New(PAniItem,Init(AView,R,AniNone,25,0,1));
  266.     AniList^.Insert(AniItem);
  267.  
  268.     R.Assign(5,3,35,4);
  269.     AView:=New(PStaticText,Init(R,'(or at least cute)'));
  270.     Insert(AView);
  271.     R.Assign(5,1,35,11);
  272.     AniItem:=New(PAniItem,Init(AView,R,AniNone,25,0,1));
  273.     AniList^.Insert(AniItem);
  274.  
  275.     R.Assign(5,4,35,5);
  276.     AView:=New(PStaticText,Init(R,'send me some CompuServe EMail!'));
  277.     Insert(AView);
  278.     R.Assign(5,1,35,11);
  279.     AniItem:=New(PAniItem,Init(AView,R,AniNone,25,0,1));
  280.     AniList^.Insert(AniItem);
  281.  
  282.     R.Assign(5,5,35,6);
  283.     AView:=New(PStaticText,Init(R,'Tim Schempp 71224,455'));
  284.     Insert(AView);
  285.     R.Assign(5,1,35,11);
  286.     AniItem:=New(PAniItem,Init(AView,R,AniNone,25,0,1));
  287.     AniList^.Insert(AniItem);
  288.  
  289.     R.Assign(1,11,11,13);
  290.     AView:=New(PButton,Init(R,'~O~k',cmOk,bfDefault));
  291.     Insert(AView);
  292.     AniItem:=New(PAniItem,Init(AView,Boundry,AniBounceBack,10,-1,0));
  293.     AniList^.Insert(AniItem);
  294.    end; {with}
  295.  
  296.   DeskTop^.ExecView(PAbout);
  297.   Dispose(PAbout,Done);
  298.  
  299.   PAbout:=nil;   {Don't forget to do this!!!}
  300.  end;
  301.  
  302. {******}
  303.  
  304.  procedure TTestApp.BounceBox;
  305.  
  306.  var  R:TRect;
  307.       Boundry:TRect;
  308.       AView:PView;
  309.       AniItem:PAniItem;
  310.  
  311.  begin
  312.   R.Assign(0,0,49,13);
  313.   PBounceBox:=New(PAnimateDialog,Init(R,'Bouncing Dialog'));
  314.  
  315.   with PBounceBox^ do
  316.    begin
  317.     DeskTop^.GetExtent(Boundry);
  318.     Inc(Boundry.A.X,1);
  319.     Inc(Boundry.B.X,-1); Inc(Boundry.B.Y,-1);
  320.  
  321.     AniItem:=New(PAniItem,Init(PBounceBox,Boundry,AniBounceAround,10,1,1));
  322.     AniList^.Insert(AniItem);
  323.  
  324.     R.Assign(10,2,39,3);
  325.     AView:=New(PStaticText,Init(R,'This is a Bouncing Dialog Box'));
  326.     Insert(AView);
  327.  
  328.     R.Assign(15,4,34,7);
  329.     AView := New(PRadioButtons, Init(R,
  330.                                      NewSItem('~I~ Like it!',
  331.                                      NewSItem('I ~D~islike it!',
  332.                                      NewSItem('I~t~''s annoying!', nil)))));
  333.     Insert(AView);
  334.  
  335.     R.Assign(1,8,15,10);
  336.     AView:=New(PButton,Init(R,'~H~orizontal',cmBounceDH,bfNormal));
  337.     Insert(AView);
  338.  
  339.     R.Assign(17,8,31,10);
  340.     AView:=New(PButton,Init(R,'~V~erticle',cmBounceDV,bfNormal));
  341.     Insert(AView);
  342.  
  343.     R.Assign(33,8,47,10);
  344.     AView:=New(PButton,Init(R,'~A~round',cmBounceDA,bfNormal));
  345.     Insert(AView);
  346.  
  347.     R.Assign(17,10,31,12);
  348.     AView:=New(PButton,Init(R,'~O~k',cmOk,bfDefault));
  349.     Insert(AView);
  350.    end; {with}
  351.  
  352.   DeskTop^.ExecView(PBounceBox);
  353.   Dispose(PBounceBox,Done);
  354.   PBounceBox:=nil;      {Don't forget to do this!!!}
  355.  end;
  356.  
  357. {******}
  358.  
  359.  procedure TTestApp.DataEntry;
  360.  
  361.  var  R,R2:TRect;
  362.       Boundry:TRect;
  363.       AView,View2:PView;
  364.       AniItem:PAniItem;
  365.       OrigState:Boolean;
  366.  
  367.  begin
  368.   OrigState:=AnimationOff;
  369.   AnimationOff:=True;
  370.  
  371.   R.Assign(12, 0, 67, 23);
  372.   PDataEntryBox:=New(PAnimateDialog,Init(R,'Data Entry'));
  373.  
  374.   with PDataEntryBox^ do
  375.    begin
  376.     GetExtent(Boundry);
  377.     Inc(Boundry.A.X,1);  Inc(Boundry.A.Y,1);
  378.     Inc(Boundry.B.X,-1); Inc(Boundry.B.Y,-1);
  379.  
  380.     R.Assign(4, 2, 52, 3);
  381.     AView := New(PStaticText, Init(R, 'This may look like a common data entr'+
  382.                                       'y screen...'));
  383.     Insert(AView);
  384.     AniItem:=New(PAniItem,Init(AView,Boundry,AniBounceBack,12,-1,0));
  385.     AniList^.Insert(AniItem);
  386.  
  387.  
  388.     R2.Assign(4,4,50,7);
  389.  
  390.     R.Assign(15, 4, 50, 5);
  391.     AView:= New(PInputLine, Init(R, 40));
  392.     Insert(AView);
  393.     AniItem:=New(PAniItem,Init(AView,R2,AniNone,125,0,2));
  394.     AniList^.Insert(AniItem);
  395.  
  396.     R.Assign(4, 4, 12, 5);
  397.     View2:=New(PLabel, Init(R, '~N~ame', AView));
  398.     Insert(View2);
  399.     AniItem:=New(PAniItem,Init(View2,R2,AniNone,125,0,2));
  400.     AniList^.Insert(AniItem);
  401.  
  402.     R.Assign(15, 6, 50, 7);
  403.     AView := New(PInputLine, Init(R, 40));
  404.     Insert(AView);
  405.     AniItem:=New(PAniItem,Init(AView,R2,AniNone,125,0,2));
  406.     AniList^.Insert(AniItem);
  407.  
  408.     R.Assign(4, 6, 12, 7);
  409.     View2:=New(PLabel, Init(R, '~A~ddress', AView));
  410.     Insert(View2);
  411.     AniItem:=New(PAniItem,Init(View2,R2,AniNone,125,0,2));
  412.     AniList^.Insert(AniItem);
  413.  
  414.     R2.Assign(4,8,50,10);
  415.  
  416.     R.Assign(15, 8, 27, 9);
  417.     AView := New(PInputLine, Init(R, 15));
  418.     Insert(AView);
  419.     AniItem:=New(PAniItem,Init(AView,R2,AniBounceBack,30,0,1));
  420.     AniList^.Insert(AniItem);
  421.  
  422.     R.Assign(4, 8, 12, 9);
  423.     View2:=New(PLabel, Init(R, 'P~h~one #', AView));
  424.     Insert(View2);
  425.     AniItem:=New(PAniItem,Init(View2,R2,AniBounceBack,30,0,1));
  426.     AniList^.Insert(AniItem);
  427.  
  428.     R.Assign(38, 8, 50, 10);
  429.     AView := New(PRadioButtons, Init(R,
  430.       NewSItem('Male',
  431.       NewSItem('Female', Nil))));
  432.     Insert(AView);
  433.     AniItem:=New(PAniItem,Init(AView,R2,AniBounceBack,30,0,1));
  434.     AniList^.Insert(AniItem);
  435.  
  436.     R.Assign(33, 8, 37, 9);
  437.     View2:=New(PLabel, Init(R, '~S~ex', AView));
  438.     Insert(View2);
  439.     AniItem:=New(PAniItem,Init(View2,R2,AniBounceBack,30,0,1));
  440.     AniList^.Insert(AniItem);
  441.  
  442.     R.Assign(15, 11, 46, 14);
  443.     AView := New(PMemo, Init(R, Nil, Nil, Nil, 255));
  444.     Insert(AView);
  445.     R2.Assign(15,11,50,14);
  446.     AniItem:=New(PAniItem,Init(AView,R2,AniBounceBack,10,1,0));
  447.     AniList^.Insert(AniItem);
  448.  
  449.     R.Assign(3, 11, 10, 12);
  450.     View2:=New(PLabel, Init(R, '~R~emark', AView));
  451.     Insert(View2);
  452.     R2.Assign(3,11,10,14);
  453.     AniItem:=New(PAniItem,Init(View2,R2,AniBounceBack,20,0,1));
  454.     AniList^.Insert(AniItem);
  455.  
  456.     R.Assign(16, 15, 45, 18);
  457.     AView := New(PCheckboxes, Init(R,
  458.       NewSItem('Please Send Information',
  459.       NewSItem('Please Call Me',
  460.       NewSItem('Don''t Contact Me', Nil)))));
  461.     Insert(AView);
  462.     R.Assign(1,15,55,22);
  463.     AniItem:=New(PAniItem,Init(AView,R,AniBounceAround,10,-1,-1));
  464.     AniList^.Insert(AniItem);
  465.  
  466.     R.Assign(4, 19, 14, 21);
  467.     AView := New(PButton, Init(R, 'O~k~', cmOK, bfDefault));
  468.     Insert(AView);
  469.     AniItem:=New(PAniItem,Init(AView,Boundry,AniNone,15,0,1));
  470.     AniList^.Insert(AniItem);
  471.  
  472.     R.Assign(21, 19, 31, 21);
  473.     AView := New(PButton, Init(R, '~C~ancel', cmCancel, bfNormal));
  474.     Insert(AView);
  475.     AniItem:=New(PAniItem,Init(AView,Boundry,AniNone,15,0,1));
  476.     AniList^.Insert(AniItem);
  477.  
  478.     R.Assign(39, 19, 50, 21);
  479.     AView := New(PButton, Init(R, '~P~ush Me', cmSubView, bfNormal));
  480.     Insert(AView);
  481.     AniItem:=New(PAniItem,Init(AView,Boundry,AniNone,15,0,1));
  482.     AniList^.Insert(AniItem);
  483.  
  484.     SelectNext(False);
  485.    end; {with}
  486.  
  487.   DeskTop^.ExecView(PDataEntryBox);
  488.   Dispose(PDataEntryBox,Done);
  489.   PDataEntryBox:=nil;     {Don't forget to do this!!!}
  490.  
  491.   AnimationOff:=OrigState;
  492.  end;
  493.  
  494. {******}
  495.  
  496.  procedure TTestApp.SubView;
  497.  
  498.  var  R:TRect;
  499.       Boundry:TRect;
  500.       AView:PView;
  501.       AniItem:PAniItem;
  502.  
  503.  begin
  504.   R.Assign(20, 4, 61, 17);
  505.   PSubView:=New(PAnimateDialog,Init(R,'Foreground/Background Animation'));
  506.  
  507.   with PSubView^ do
  508.    begin
  509.     GetExtent(Boundry);
  510.     Inc(Boundry.A.X,1);  Inc(Boundry.A.Y,1);
  511.     Inc(Boundry.B.X,-1); Inc(Boundry.B.Y,-1);
  512.  
  513.     R.Assign(12, 2, 28, 3);
  514.     AView := New(PStaticText, Init(R, 'Choose a Button!'));
  515.     Insert(AView);
  516.     AniItem:=New(PAniItem,Init(AView,Boundry,AniBounceAround,2,2,1));
  517.     AniList^.Insert(AniItem);
  518.  
  519.     R.Assign(20, 1, 21, 2);
  520.     AView := New(PStaticText, Init(R, '*'));
  521.     Insert(AView);
  522.     AniItem:=New(PAniItem,Init(AView,Boundry,AniBounceAround,2,2,1));
  523.     AniList^.Insert(AniItem);
  524.  
  525.     R.Assign(20, 11, 21, 12);
  526.     AView := New(PStaticText, Init(R, '*'));
  527.     Insert(AView);
  528.     AniItem:=New(PAniItem,Init(AView,Boundry,AniBounceAround,2,2,1));
  529.     AniList^.Insert(AniItem);
  530.  
  531.     R.Assign(12, 9, 28, 11);
  532.     AView := New(PButton, Init(R, '~D~one', cmOk, bfDefault));
  533.     Insert(AView);
  534.     AniItem:=New(PAniItem,Init(AView,Boundry,AniBounceAround,2,-1,1));
  535.     AniList^.Insert(AniItem);
  536.  
  537.     R.Assign(10, 4, 30, 8);
  538.     AView := New(PButton, Init(R, '~T~oggle Animation', cmAniToggle, bfNormal));
  539.     Insert(AView);
  540.     SelectNext(False);
  541.    end; {with}
  542.  
  543.   DeskTop^.ExecView(PSubView);
  544.   Dispose(PSubView,Done);
  545.   PSubView:=nil;    {Don't forget to do this!!!}
  546.  end;
  547.  
  548. {******}
  549.  
  550.  procedure TTestApp.WinDialog;
  551.  
  552.  var  R:TRect;
  553.       Boundry:TRect;
  554.       AView:PView;
  555.       Window:PWindow;
  556.       AniItem:PAniItem;
  557.       Counter:Integer;
  558.  
  559.  {*}
  560.  procedure AddToList(P:PView); far;
  561.   var AniItem:PAniItem;
  562.  begin
  563.   AniItem:=New(PAniItem,Init(P,Boundry,AniBounceAround,7,Random(5)-2,Random(5)-2));
  564.   PWinDialog^.AniList^.Insert(AniItem);
  565.  end;
  566.  {*}
  567.  
  568.  begin
  569.   Randomize;
  570.   MakeWindows; {Add some Windows to the DeskTop}
  571.   MessageBox('First we''ll insert some windows into the DeskTop.'
  572.              ,nil,mfOkButton+mfInformation);
  573.  
  574.   R.Assign(20, 3, 61, 19);
  575.   PWinDialog:=New(PAnimateDialog,Init(R,'DeskTop Animation'));
  576.   PWinDialog^.UpDateOn:=False;
  577.   PWinDialog^.SpecialKey:=kbAltA;
  578.  
  579.   {Why not capture the whole desktop?}
  580.   DeskTop^.GetExtent(Boundry);
  581.   Inc(Boundry.A.X,1);  Inc(Boundry.A.Y,1);
  582.   Inc(Boundry.B.X,-1); Inc(Boundry.B.Y,-1);
  583.   DeskTop^.ForEach(@AddToList);
  584.  
  585.   with PWinDialog^ do
  586.    begin
  587.     GetExtent(Boundry);
  588.     Inc(Boundry.A.X,1);  Inc(Boundry.A.Y,1);
  589.     Inc(Boundry.B.X,-1); Inc(Boundry.B.Y,-1);
  590.  
  591.     R.Assign(4, 2, 38, 10);
  592.     AView := New(PStaticText, Init(R, 'In this example, the whole DeskTop has'+
  593.                  ' been captured with a DeskTop^.ForEach procedure. Although'+
  594.                  ' F9 Toggles the Global Dialog'+
  595.                  ' Animation, each Dialog Box can have its own Hot Key.'+
  596.                  '  Press Alt-A or Double Click on the "***" below to get'+
  597.                  ' this one started.'));
  598.     Insert(AView);
  599.  
  600.     R.Assign(19, 11, 22, 12);
  601.     AView := New(PStaticText, Init(R, '***'));
  602.     Insert(AView);
  603.     AniItem:=New(PAniItem,Init(AView,Boundry,AniBounceBack,5,1,0));
  604.     AniList^.Insert(AniItem);
  605.     PWinDialog^.SpecialView:=AView; {Now the view activates the Dialog!}
  606.  
  607.     R.Assign(10,13, 30, 15);
  608.     AView := New(PButton, Init(R, '~D~one', cmOk, bfDefault));
  609.     Insert(AView);
  610.    end; {with}
  611.  
  612.   DeskTop^.ExecView(PWinDialog);
  613.   PWinDialog^.RestoreViews;
  614.   R.Assign(20,6,60,16);
  615.   MessageBoxRect(R,'By calling TAnimateDialog''s RestoreViews (before '
  616.                   +'Disposing of it!) the Views will be restored to '
  617.                   +' thier starting positions!'
  618.                   ,nil,mfOkButton+mfInformation);
  619.   Dispose(PWinDialog,Done);
  620.  
  621.   PWinDialog:=nil;      {Don't forget to do this!!!}
  622.  
  623.   repeat until Message(DeskTop^.TopView,evCommand,cmClose,nil)=nil;
  624.  end;
  625.  
  626. {******}
  627.  
  628.  procedure TTestApp.MakeWindows;
  629.  
  630.  var P:PWindow;
  631.      R:TRect;
  632.      AniItem:PAniItem;
  633.      A,B:Integer;
  634.  
  635.  begin
  636.   R.Assign(1,1,38,10);
  637.   P:=New(PWindow,Init(R,'Top Left Window',wnNoNumber));
  638.   DeskTop^.Insert(P);
  639.   R.Assign(40,1,78,10);
  640.   P:=New(PWindow,Init(R,'Top Right Window',wnNoNumber));
  641.   DeskTop^.Insert(P);
  642.   R.Assign(1,12,38,21);
  643.   P:=New(PWindow,Init(R,'Bottom Left Window',wnNoNumber));
  644.   DeskTop^.Insert(P);
  645.   R.Assign(40,12,78,21);
  646.   P:=New(PWindow,Init(R,'Bottom Right Window',wnNoNumber));
  647.   DeskTop^.Insert(P);
  648.  end;
  649.  
  650. {******}
  651.  
  652.  procedure TTestApp.ExitDialog;
  653.  
  654.  var  R:TRect;
  655.       Boundry:TRect;
  656.       AView:PView;
  657.       AniItem:PAniItem;
  658.  
  659.  begin
  660.   R.Assign(20, 4, 60, 20);
  661.   PExitDialog:=New(PAnimateDialog,Init(R,'Exit Dialog'));
  662.  
  663.   with PExitDialog^ do
  664.    begin
  665.     R.Assign(4, 2, 38, 3);
  666.     AView := New(PStaticText, Init(R, 'To Exit, Click the Exit Button...'));
  667.     Insert(AView);
  668.  
  669.     R.Assign(8, 3, 35, 4);
  670.     AView := New(PStaticText, Init(R, 'Or cheat and press Enter'));
  671.     Insert(AView);
  672.  
  673.     R.Assign(5, 5, 15, 7);
  674.     AView := New(PButton, Init(R, '~C~ancel', cmCancel, bfNormal));
  675.     Insert(AView);
  676.  
  677.     R.Assign(25, 5, 35, 7);
  678.     AView := New(PButton, Init(R, '~S~lower', cmSlower, bfNormal));
  679.     Insert(AView);
  680.  
  681.     R.Assign(15, 7, 25, 9);
  682.     AView := New(PButton, Init(R, '~E~xit', cmOk, bfDefault));
  683.     Insert(AView);
  684.     R.Assign(1,7,39,15);
  685.     AniItem:=New(PAniItem,Init(AView,R,AniBounceAround,0,1,1));
  686.     AniList^.Insert(AniItem);
  687.  
  688.    end; {with}
  689.  
  690.   if DeskTop^.ExecView(PExitDialog)=cmOk
  691.      then Message(@Self,evCommand,cmQuit,nil);
  692.   Dispose(PExitDialog,Done);
  693.   PExitDialog:=nil;     {Don't forget to do this!!!}
  694.  end;
  695.  
  696. {******}
  697.  
  698.  var TestApp:TTestApp;
  699.  
  700.  begin
  701.   TestApp.Init;
  702.   TestApp.Run;
  703.   TestApp.Done;
  704.  end.