【发布时间】:2014-12-19 12:17:18
【问题描述】:
首先很抱歉,如果以前出现过这种情况,但我正在努力寻找有关此事的任何信息。
我正在尝试将许多 TImage 添加到滚动框,该滚动框旨在保存图像并允许用户滚动它们。此创建是在运行时完成的。
图像存储在 TImage 数组中。
以下是我必须创建图像的代码。
procedure TfrmMain.CreateSolutionImages(ImageCount: Integer);
var
I: Integer;
ImageScale: double;
begin
if sbSolutionImages.ComponentCount > 0 then //destroy the images already in the scrollbox
sbSolutionImages.DestroyComponents;
SetLength(SolutionImages,0); //clear the array of images
SetLength(SolutionImages,ImageCount); //SolutionImages is an array of timage
ImageScale:= ((sbSolutionImages.Width - 20)/Guillotine.StockWidth);
for I := 0 to ImageCount - 1 do
begin
if not Assigned(SolutionImages[I]) then //if not assigned then create and set the parent to the scrollbox
begin
SolutionImages[I]:= TImage.Create(sbSolutionImages);
SolutionImages[I].Parent:= sbSolutionImages;
SolutionImages[I].Width:= trunc(Guillotine.StockWidth * ImageScale); //set image dimentions and positions
SolutionImages[I].Height:= trunc(Guillotine.StockHeight * ImageScale);
SolutionImages[I].Position.X:= 10;
if I = 0 then
begin
SolutionImages[I].Position.Y:= 10;
end
else
begin
SolutionImages[I].Position.Y:= SolutionImages[I-1].Position.Y + SolutionImages[I-1].Height + 20;
end;
end;
//forgot to include these lines
SolutionImages[I].Bitmap.SetSize(Round(SolutionImages[I].Width),Round(SolutionImages[I].Height));
SolutionImages[I].Bitmap.Clear(TAlphaColors.White);
end;
end;
正在发生的事情是滚动框 (sbSolutionImages) 报告它包含图像,即组件数增加,但是它没有绘制图像并且没有出现滚动条,这在逻辑上应该发生,因为某些图像不会在可视区域内。
任何帮助将不胜感激。
【问题讨论】:
标签: delphi firemonkey delphi-xe6