home *** CD-ROM | disk | FTP | other *** search
- (***************************************
- * WG-VISION 1.0 BEISPIELPROGRAMM *
- ****************************************
- * *
- * Anzeigen des verfügbaren Speichers *
- * (Heap, EMS, Festplatte C) in einen *
- * Dialogfenster *
- * *
- ****************************************
- * (c) 1993 Dipl.Phys. Mathias Scholz *
- ***************************************)
-
- {$I COMPILER.INC}
-
- program Memory1;
-
- uses WDecl,
- WEvent,
- WUtils,
- WApp,
- WViews,
- WDlg,
- Graph;
-
-
- const cmGetMemory=101;
-
- type TApplication=object(TApp)
- procedure InitMenuBar; virtual;
- procedure HandleEvent; virtual;
- procedure GetMemoryStatus;
- end;
-
- PMemoryInfo=^TMemoryInfo;
- TMemoryInfo=object(TWindow)
- constructor Init;
- procedure InitBackground; virtual;
- end;
-
- PMemoryInfoBgrd=^TMemoryInfoBgrd;
- TMemoryInfoBgrd=object(TBackground)
- procedure Draw; virtual;
- end;
-
-
- var MyApp:TApplication;
-
-
- {Implementation TApplication}
-
- procedure TApplication.InitMenuBar;
- begin
- MainMenu('~F~enster',0);
- SubMenu('~S~peicher-Ressourcen',cmGetMemory,0,0,false,false);
- SubMenu('E~x~it Alt+X',cmCloseApplication,0,altX,false,false);
- end;
-
- procedure TApplication.HandleEvent;
- begin
- TProgram.HandleEvent;
- case Event.Command of
- cmGetMemory:GetMemoryStatus;
- end; {case}
- end;
-
- procedure TApplication.GetMemoryStatus;
- var Window:PMemoryInfo;
- begin
- Window:=New(PMemoryInfo, Init);
- InsertDesktop(Window);
- end;
-
- {Implementation TMemoryInfo}
-
- constructor TMemoryInfo.Init;
- var R:TRect;
- begin
- R.Assign(60,80,450,320);
- TWindow.Init(R,'Speicher-Ressourcen',winDouble+winPanel+winMenu);
- SetWindowAttrib(false);
- end;
-
- procedure TMemoryInfo.InitBackground;
- var R:TRect;
- begin
- R:=Frame^.Area;
- Bgrd:=New(PMemoryInfoBgrd, Init(R));
- List^.InsertItem(Bgrd);
- end;
-
- {Implementation TMemoryInfoBgrd}
-
- procedure TMemoryInfoBgrd.Draw;
- var z:string;
- EMS:PEMS;
- HD:PHardDisk;
- begin
- with Border do
- begin
- FillBar(A.X,A.Y,B.X,B.Y,Yellow,White,SolidFill);
- Str(MemAvail:8,z);
- SetColor(Red);
- OutTextXY(A.X+10,A.Y+25,'Hauptspeicher');
- OutTextXY(A.X+10,A.Y+100,'Expanded Memory');
- OutTextXY(A.X+10,A.Y+160,'Festplatte C');
- SetColor(Blue);
- OutTextXY(A.X+10,A.Y+45,'freier RAM (Heap) : '+z+' Byte');
- Str(MaxAvail:8,z);
- OutTextXY(A.X+10,A.Y+65,'größter zusammenhängender');
- OutTextXY(A.X+10,A.Y+75,'freier Speicherblock : '+z+' Byte');
- EMS:=New(PEMS, Init(Border));
- Str(EMS^.FreeMemory:8,z);
- OutTextXY(A.X+10,A.Y+120,'verfügbarer Speicher : '+z+' Byte');
- Str(EMS^.FreeMemory div 16384:8,z);
- OutTextXY(A.X+10,A.Y+140,'verfügbare Seiten : '+z+' Pages');
- Dispose(EMS, Done);
- HD:=New(PHardDisk, Init(Border));
- Str(HD^.FreeMemory:8,z);
- OutTextXY(A.X+10,A.Y+180,'verfügbare Plattenkapazität : '+z+' Byte');
- Dispose(HD, Done);
- end;
- end;
-
- {Hauptprogramm}
-
- begin
- MyApp.Init('Speicher-Ressourcen');
- MyApp.Run;
- MyApp.Done;
- end.
-