如何清除scrollbox中控件?
我在编写一个类似acdsee的图片浏览工具,我用的方法是在scrollbox中
动态的创建Timage控件并同时将图片载入。我现在困惑的是,打开另外一个
文件夹的时候原来的图片仍然在,无法清楚,这是什么原因呢?
。。。
for i:=0 to scrollbox1.ComponentCount-1 do
begin
scrollbox1.components[i].free;
end;
scrollbox1.Refresh;
scrollbox1.Realign;
scrollbox1.Repaint;
scrollbox1.VertScrollBar.Position:=0;
for i:=0 to FileCount do
begin
testcc:=timage.Create(self);
testcc.Picture.LoadFromFile('c:\Store_Small_photo\'+FileList[i]);
GetJpegSize('c:\Store_Small_photo\'+FileList[i],tempwidth,tempheight);
testcc.Left:=x;
testcc.Top:=y;
testcc.Parent:=scrollbox1;
testcc.Width:=tempwidth;
testcc.Height:=tempheight;
testcc.Visible:=true;
inc(x,122);
if x>264 then
begin x:=20; inc(y,120); end;
application.processmessages;
end;
。。。