L
ljdzxx
Unregistered / Unconfirmed
GUEST, unregistred user!
我想显示一个文件夹中的所有图片,图片路径已存放在一个TStrings中,过程如下:
procedure TF_ShowFace.PrintFace(Sl: TStrings);
var
Arr_Face: array of Timage;
i:Integer;
begin
SetLength(Arr_Face,Sl.Count);
try
for i := 0 to Sl.Count-1 do
begin
Arr_Face:=Timage.Create(self);
Arr_Face.parent:=self.Panel_Main;
Arr_Face.Picture.LoadFromFile(Sl.Strings);
Arr_Face.Width:=Arr_Face.Picture.Width;
Arr_Face.Height:=Arr_Face.Picture.Height;
Arr_Face.Left:=24;
Arr_Face.Top:= i*100+10;
end;
finally
Sl.Free;
end;
end;
可报错了,错误信息如下:
project project1.exe raised exception class EAccessViolation with message'Access violation at address 00000004. Read of address 00000004'.Process stopped. Use Step or Run to continue.
是什么原因呢,我的程序代码有问题吗?Sl我输出来看了,是没有问题的
procedure TF_ShowFace.PrintFace(Sl: TStrings);
var
Arr_Face: array of Timage;
i:Integer;
begin
SetLength(Arr_Face,Sl.Count);
try
for i := 0 to Sl.Count-1 do
begin
Arr_Face:=Timage.Create(self);
Arr_Face.parent:=self.Panel_Main;
Arr_Face.Picture.LoadFromFile(Sl.Strings);
Arr_Face.Width:=Arr_Face.Picture.Width;
Arr_Face.Height:=Arr_Face.Picture.Height;
Arr_Face.Left:=24;
Arr_Face.Top:= i*100+10;
end;
finally
Sl.Free;
end;
end;
可报错了,错误信息如下:
project project1.exe raised exception class EAccessViolation with message'Access violation at address 00000004. Read of address 00000004'.Process stopped. Use Step or Run to continue.
是什么原因呢,我的程序代码有问题吗?Sl我输出来看了,是没有问题的