请问各位大侠,现要将磁盘目录中的位图文件按一定比例缩小后显示在ListView控件中,显示的结果就像“我的电脑”里的模样,上面是图标,下面是文件名?谢谢!
我在运行了下面得代码后,显示得结果是:取出了目录中所有位图文件的文件名,但是只调出了第一个位图文件(图),并且将这副图分成几块显示在ListView控件的控件中,美块下面分别是目录中文件的文件名,请问这是为什么?
var
templi: Tlistitem;
tempbmp: Tbitmap;
strDir,Dir:string;
f:TSearchRec;
FileName:String;
i,j:integer;
begin
ListView1.Clear;
strDir:='e:/bmp/';
if strDir[Length(strDir)]<>'/' then
strDir:=strDir+'/'
else
Dir:=strDir+'*.bmp';
if FindFirst(Dir,faAnyFile,f)=0 then
begin
i:=0; repeat
strDir:='e:/bmp/';
FileName:=f.Name;
strDir:=strDir+FileName;
templi:= listview1.Items.Add;
templi.Caption:= FileName;
tempbmp:=Tbitmap.Create;
tempbmp.LoadFromFile(strDir);
j:=imagelist1.add(tempbmp,nil);
ListView1.SmallImages:=nil;
templi.ImageIndex:= i;
i:=i+1;
tempbmp.Dormant;
tempbmp.FreeImage;
tempbmp.ReleaseHandle;
tempbmp.Free;
tempbmp:=nil;
until FindNext(f)<>0; end;
我在运行了下面得代码后,显示得结果是:取出了目录中所有位图文件的文件名,但是只调出了第一个位图文件(图),并且将这副图分成几块显示在ListView控件的控件中,美块下面分别是目录中文件的文件名,请问这是为什么?
var
templi: Tlistitem;
tempbmp: Tbitmap;
strDir,Dir:string;
f:TSearchRec;
FileName:String;
i,j:integer;
begin
ListView1.Clear;
strDir:='e:/bmp/';
if strDir[Length(strDir)]<>'/' then
strDir:=strDir+'/'
else
Dir:=strDir+'*.bmp';
if FindFirst(Dir,faAnyFile,f)=0 then
begin
i:=0; repeat
strDir:='e:/bmp/';
FileName:=f.Name;
strDir:=strDir+FileName;
templi:= listview1.Items.Add;
templi.Caption:= FileName;
tempbmp:=Tbitmap.Create;
tempbmp.LoadFromFile(strDir);
j:=imagelist1.add(tempbmp,nil);
ListView1.SmallImages:=nil;
templi.ImageIndex:= i;
i:=i+1;
tempbmp.Dormant;
tempbmp.FreeImage;
tempbmp.ReleaseHandle;
tempbmp.Free;
tempbmp:=nil;
until FindNext(f)<>0; end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货