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

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