home *** CD-ROM | disk | FTP | other *** search
/ Best of German Only 1 / romside_best_of_german_only_1.iso / wissen / dos / wgraph / entpack.exe / WGBSP!.EXE / BSP12.PAS < prev    next >
Pascal/Delphi Source File  |  1992-12-17  |  2KB  |  78 lines

  1. program Beispiel12;
  2.  
  3. uses GDecl,
  4.      GApp,
  5.      GEvent,
  6.      GViews,
  7.      GDlg,
  8.      Graph;
  9.  
  10.  
  11. const cmStandard        = 101;
  12.       cmCloseAllWindows = 102;
  13.  
  14. type TApplication=object(TApp)
  15.        procedure InitMenuBar; virtual;
  16.        procedure HandleEvent; virtual;
  17.        procedure NewWindow;
  18.        procedure CloseAllWindows;
  19.      end;
  20.  
  21. var MyProg:TApplication;
  22.  
  23. {Implementation TApplication}
  24.  
  25. procedure TApplication.InitMenuBar;
  26. begin
  27.   MainMenu('~F~enster',0);
  28.    SubMenu('~Z~ufalls-Fenster  F8',cmStandard,0,kbF8,false,false);
  29.    SubMenu('~F~enster schließen',cmCloseAllWindows,0,0,false,false);
  30.    SubMenu('E~x~it  Alt-X',cmCloseApplication,0,altX,false,false);
  31. end;
  32.  
  33. procedure TApplication.HandleEvent;
  34. begin
  35.   Heap^.ShowHeapStatus(523,8,White);
  36.   TProgram.HandleEvent;
  37.   case Event.Command of
  38.    cmStandard        : NewWindow;
  39.    cmCloseAllWindows : CloseAllWindows;
  40.   end; {case}
  41. end;
  42.  
  43.  
  44. procedure TApplication.NewWindow;
  45. var R:TRect;
  46.     x,y:integer;
  47.     Window:PWindow;
  48. begin
  49.   x:=Random(480)+4;
  50.   y:=Random(328)+48;
  51.   R.Assign(x,y,x+150,y+100);
  52.   Window:=new(PWindow, Init(R,'ZufallsFenster',winDouble+winPanel+winMenu+winKey));
  53.   InsertDesktop(Window);
  54. end;
  55.  
  56. procedure TApplication.CloseAllWindows;
  57. var i:integer;
  58.     LfdPtr:PGroup;
  59. begin
  60.   with Desktop^ do
  61.    begin
  62.      for i:=WinCount downto 1 do
  63.       begin
  64.         LfdPtr:=WinList^.GetItems(i);
  65.         LfdPtr^.Hide;
  66.         WinList^.DelLastItem;
  67.       end;
  68.      WinCount:=0; WinAnz:=0;
  69.    end;
  70. end;
  71.  
  72. {Hauptprogramm}
  73.  
  74. begin
  75.   MyProg.Init('Beispiel 12');
  76.   MyProg.Run;
  77.   MyProg.Done;
  78. end.