
19.08.2009, 00:10
|
 |
Начинающий
|
|
Регистрация: 13.12.2008
Адрес: Туапсе
Сообщения: 161
Репутация: 20
|
|
Код:
unit Unit1;
interface
type
//базоый объект
TMyCustomObject = class
constructor Create;
destructor Destroy; override;
end;
procedure Clear;
function IsValidObject(Obj : TObject) : Boolean;
implementation
Uses
Classes;
var
Objects : TList;
procedure Clear;
var
i : Integer;
begin
for I := 0 to Objects.Count - 1 do TObject(Objects[0]).free;
end;
//функция проверки
function IsValidObject(Obj : TObject) : Boolean;
begin
Result := Objects.IndexOf(Obj) <> -1;
end;
{ TMyCustomObject }
constructor TMyCustomObject.Create;
begin
Objects.Add(self);
end;
destructor TMyCustomObject.Destroy;
var
index : Integer;
begin
index := Objects.IndexOf(self);
if index <> -1 then Objects.Delete(index);
inherited;
end;
initialization
Objects := TList.Create;
finalization
Clear;
Objects.Free;
end.
__________________
...сказал, и загрустил от бесспорной своей правоты
|