첫 번째로 미안하지만이 문제가 전에 제기되었지만 문제에 관해 무엇인가를 찾으려고 애 쓰고 있습니다.Firemonkey XE6에서 TScrollBox에 Timage를 추가하는 방법은 무엇입니까?
많은 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)가 논리적으로 일부 이미지로 일해야하는, 그러나 그것은 이미지를 그리기되지 않고 스크롤 막대가 표시되지, 그것은 이미지, 즉 componentcount 증가 포함되어 있음을보고 있다는 것입니다 볼 수있는 영역에 있지 않습니다.
도움을 주시면 감사하겠습니다.
Hello Mike. 당신의 응답을 주셔서 감사합니다. 나는 이것을 한 발씩주고 결과를 업데이트 할 것이다. – Jarryd
Ok Mike. 그 트릭을했습니다. 난 그냥 이미지의 크기와 양에 의해 레이아웃의 높이를 업데이 트하고 그것은 매력처럼 작동합니다. 감사 – Jarryd