给你一段代码看看:
i:=1;
l:=6;
h:=6;
t:=frmtxlr.divstr(s,i);
if t<>'' then label9.Hide;
while t<>'' do
begin
img:=timage.Create(tsheetTxdz);
img.parent:=tsheetTxdz;
img.Name:='img'+copy(t,7,8);
img.Stretch:=true;
img.Width:=150;
img.Height:=150;
img.Left:=l;
img.Top:=h;
img.Tag:=i-length(t)-1;
lab:=tlabel.Create(tsheettxdz);
lab.parent:=tsheetTxdz;
lab.Name:='lab'+copy(t,7,8);
lab.AutoSize:=false;
lab.Alignment:=tacenter;
lab.Width:=img.Width;
lab.Left:=img.Left;
lab.Top:=img.Top+img.Height+4;
lab.Font.Color:=clred;
lab.Caption:=copy(t,7,4)+'年'+copy(t,11,2)+'月'+copy(t,13,2)+'日';
if fileexists(sExePath+'graph/'+t) then
begin
img.Picture.LoadFromFile(sExePath+'graph/'+t);
img.OnClick:=imgtxxs;
img.Hint:=lab.Caption;
img.ShowHint:=true;
end
else
begin
img.Canvas.Create;
//img.Canvas.pen.
img.Canvas.Font.Name:='宋体';
img.Canvas.Font.Size:=10;
img.Canvas.Font.Color:=clblue;
img.Canvas.TextOut(img.width div 2-20,img.height div 2-6,'无图像!');
end;
l:=l+img.Width+5;
if l>6+3*(img.width+5) then
begin
l:=6;
h:=h+img.Height+30;
end;
t:=frmtxlr.divstr(s,i);
end;