home *** CD-ROM | disk | FTP | other *** search
/ TopWare 18: Liquid / Image.iso / liquid / top1143 / gepackt.exe / BSPQTSW.EXE / ZFENST.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1993-06-28  |  2.3 KB  |  94 lines

  1. (***************************************
  2. * WG-VISION 1.0   BEISPIELPROGRAMM     *
  3. ****************************************
  4. *                                      *
  5. * Erzeugung einer beliebigen Anzahl    *
  6. * von zufällig verteilten Fenstern     *
  7. *                                      *
  8. ****************************************
  9. * (c) 1993 Dipl.Phys. Mathias Scholz   *
  10. ***************************************)
  11.  
  12. {$I COMPILER.INC}
  13.  
  14. program ZFenst;
  15.  
  16. uses WApp,
  17.      WDecl,
  18.      WEvent,
  19.      WViews,
  20.      WDlg,
  21.      Graph;
  22.  
  23.  
  24. const cmStandard        = 101;
  25.       cmCloseAllWindows = 102;
  26.  
  27. type TApplication=object(TApp)
  28.        procedure InitMenuBar; virtual;
  29.        procedure HandleEvent; virtual;
  30.        procedure NewWindow;
  31.        procedure CloseAllWindows;
  32.      end;
  33.  
  34. var MyProg:TApplication;
  35.  
  36.  
  37. {Implementation TApplication}
  38.  
  39. procedure TApplication.InitMenuBar;
  40. begin
  41.   MainMenu('~F~enster',0);
  42.    SubMenu('~Z~ufalls-Fenster  F8',cmStandard,0,kbF8,false,false);
  43.    SubMenu('~F~enster schließen',cmCloseAllWindows,0,0,false,false);
  44.    SubMenu('E~x~it  Alt-X',cmCloseApplication,0,altX,false,false);
  45. end;
  46.  
  47. procedure TApplication.HandleEvent;
  48. begin
  49.   Heap^.ShowHeapStatus(523,8,White);
  50.   TProgram.HandleEvent;
  51.   case Event.Command of
  52.    cmStandard        : NewWindow;
  53.    cmCloseAllWindows : CloseAllWindows;
  54.   end; {case}
  55. end;
  56.  
  57. procedure TApplication.NewWindow;
  58. var R:TRect;
  59.     X,Y:integer;
  60.     Window:PWindow;
  61. begin
  62.   X:=Random(480)+4;
  63.   Y:=Random(328)+48;
  64.   R.Assign(X,Y,X+150,Y+100);
  65.   Window:=New(PWindow, Init(R,'ZufallsFenster',
  66.               winDouble+winPanel+winMenu+winKey));
  67.   InsertDesktop(Window);
  68. end;
  69.  
  70. procedure TApplication.CloseAllWindows;
  71. var I:integer;
  72.     LfdPtr:PGroup;
  73. begin
  74.   with DeskTop^ do
  75.    begin
  76.      for I:=WinCount downto 1 do       {WinList von hinten nach vorn abbauen}
  77.       begin
  78.         LfdPtr:=WinList^.GetItems(I);              {Pointer holen über Index}
  79.         LfdPtr^.Hide;            {Fenster schließen, Untergrund restaurieren}
  80.         WinList^.DelLastItem;           {Pointer aus der Liste entfernen und}
  81.       end;                                          {Speicherplatz freigeben}
  82.      WinCount:=0; WinAnz:=0;                                     {Das wars !}
  83.    end;
  84. end;
  85.  
  86. {Hauptprogramm}
  87.  
  88. begin
  89.   MyProg.Init('Zufallsfenster');
  90.   MyProg.Run;
  91.   MyProg.Done;
  92. end.
  93.  
  94.