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

  1. (***************************************
  2. * WG-VISION 1.0   BEISPIELPROGRAMM     *
  3. ****************************************
  4. *                                      *
  5. * Digitaluhr und Speicherstatus        *
  6. *                                      *
  7. ****************************************
  8. * (c) 1993 Dipl.Phys. Mathias Scholz   *
  9. ***************************************)
  10.  
  11. {$I COMPILER.INC}
  12.  
  13. program DigiUhr;
  14.  
  15. uses WDecl,
  16.      WEvent,
  17.      WUtils,
  18.      WApp,
  19.      WViews,
  20.      WDlg,
  21.      WUhr,
  22.      Graph;
  23.  
  24.  
  25. const cmGetMemory=101;
  26.       cmDUhr=102;
  27.  
  28. type TApplication=object(TApp)
  29.       procedure InitMenuBar; virtual;
  30.       procedure HandleEvent; virtual;
  31.       procedure GetMemoryStatus;
  32.       procedure DigitalUhr;
  33.      end;
  34.  
  35.      PMemoryInfo=^TMemoryInfo;
  36.      TMemoryInfo=object(TWindow)
  37.       constructor Init;
  38.       procedure InitBackground; virtual;
  39.      end;
  40.  
  41.      PMemoryInfoBgrd=^TMemoryInfoBgrd;
  42.      TMemoryInfoBgrd=object(TBackground)
  43.       procedure Draw; virtual;
  44.      end;
  45.  
  46. var MyApp:TApplication;
  47.  
  48.  
  49. {Implementation TApplication}
  50.  
  51. procedure TApplication.InitMenuBar;
  52. begin
  53.   MainMenu('~F~enster',0);
  54.    SubMenu('~S~peicher-Ressourcen',cmGetMemory,0,0,false,false);
  55.    SubMenu('~D~igitaluhr',cmDUhr,0,0,false,false);
  56.    SubMenu('E~x~it          Alt+X',cmCloseApplication,0,altX,false,false);
  57. end;
  58.  
  59. procedure TApplication.HandleEvent;
  60. begin
  61.   TProgram.HandleEvent;
  62.   case Event.Command of
  63.    cmGetMemory : GetMemoryStatus;
  64.    cmDUhr      : DigitalUhr;
  65.   end; {case}
  66. end;
  67.  
  68. procedure TApplication.GetMemoryStatus;
  69. var Window:PMemoryInfo;
  70. begin
  71.   Window:=New(PMemoryInfo, Init);
  72.   InsertDesktop(Window);
  73. end;
  74.  
  75. procedure TApplication.DigitalUhr;
  76. var Window:PDigitalUhr;
  77. begin
  78.   Window:=New(PDigitalUhr, Init(100,100));
  79.   InsertDesktop(Window);
  80. end;
  81.  
  82. {Implementation TMemoryInfo}
  83.  
  84. constructor TMemoryInfo.Init;
  85. var R:TRect;
  86. begin
  87.   R.Assign(60,80,450,320);
  88.   TWindow.Init(R,'Speicher-Ressourcen',winDouble+winPanel+winMenu);
  89.   SetWindowAttrib(false);
  90. end;
  91.  
  92. procedure TMemoryInfo.InitBackground;
  93. var R:TRect;
  94. begin
  95.   R:=Frame^.Area;
  96.   Bgrd:=New(PMemoryInfoBgrd, Init(R));
  97.   List^.InsertItem(Bgrd);
  98. end;
  99.  
  100. {Implementation TMemoryInfoBgrd}
  101.  
  102. procedure TMemoryInfoBgrd.Draw;
  103. var z:string;
  104.     EMS:PEMS;
  105.     HD:PHardDisk;
  106. begin
  107.   with Border do
  108.    begin
  109.      FillBar(A.X,A.Y,B.X,B.Y,Yellow,White,SolidFill);
  110.      Str(MemAvail:8,z);
  111.      SetColor(Red);
  112.      OutTextXY(A.X+10,A.Y+25,'Hauptspeicher');
  113.      OutTextXY(A.X+10,A.Y+100,'Expanded Memory');
  114.      OutTextXY(A.X+10,A.Y+160,'Festplatte C');
  115.      SetColor(Blue);
  116.      OutTextXY(A.X+10,A.Y+45,'freier RAM (Heap)           :   '+z+' Byte');
  117.      Str(MaxAvail:8,z);
  118.      OutTextXY(A.X+10,A.Y+65,'größter zusammenhängender');
  119.      OutTextXY(A.X+10,A.Y+75,'freier Speicherblock        :   '+z+' Byte');
  120.      EMS:=New(PEMS, Init(Border));
  121.      Str(EMS^.FreeMemory:8,z);
  122.      OutTextXY(A.X+10,A.Y+120,'verfügbarer Speicher        :   '+z+' Byte');
  123.      Str(EMS^.FreeMemory div 16384:8,z);
  124.      OutTextXY(A.X+10,A.Y+140,'verfügbare Seiten           :   '+z+' Pages');
  125.      Dispose(EMS, Done);
  126.      HD:=New(PHardDisk, Init(Border));
  127.      Str(HD^.FreeMemory:8,z);
  128.      OutTextXY(A.X+10,A.Y+180,'verfügbare Plattenkapazität :   '+z+' Byte');
  129.      Dispose(HD, Done);
  130.    end;
  131. end;
  132.  
  133. {auptprogramm}
  134.  
  135. begin
  136.   MyApp.Init('Speicher-Ressourcen und Digitaluhr');
  137.   MyApp.Run;
  138.   MyApp.Done;
  139. end.
  140.