Witam, jak usunać poprawnie wszystkie komponenty z formy np typu TImage?
napisalem sobie takie cos:
procedure WyczyscForme(Forma: TForm);
var
I: Integer;
begin
try
for I := 0 to Forma.ComponentCount - 1 do
if Forma.Components[I] is TImage then
Forma.Components[I].Free;
except
Exception.Create('Wystąpił błąd podczas usuwania obiektów typu TImage');
end;
end;
ale zwraca mi blad:
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EListError with message 'List index out of bounds (20)'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
oczywiscie componentow jest okolo 40 na formie, wiec czemu przy 20 cos sie dzieje?