2014-12-19 6 views
0

첫 번째로 미안하지만이 문제가 전에 제기되었지만 문제에 관해 무엇인가를 찾으려고 애 쓰고 있습니다.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 증가 포함되어 있음을보고 있다는 것입니다 볼 수있는 영역에 있지 않습니다.

도움을 주시면 감사하겠습니다.

답변

1

TLayout을 TScrollBox의 자식으로 추가하십시오. 너비와 높이를 적절하게 설정하고 Position = (0,0)을 설정하십시오. 이미지를 TLayout에 어린이로 추가하십시오.

그러면 TScrollBox는 TLayout의 경계를 알게되고이를 기반으로 스크롤 막대를 설정합니다.

+0

Hello Mike. 당신의 응답을 주셔서 감사합니다. 나는 이것을 한 발씩주고 결과를 업데이트 할 것이다. – Jarryd

+0

Ok Mike. 그 트릭을했습니다. 난 그냥 이미지의 크기와 양에 의해 레이아웃의 높이를 업데이 트하고 그것은 매력처럼 작동합니다. 감사 – Jarryd

0

죄송합니다. 그것은 단순한 어리석은 문제였습니다. 모든 이미지의 비트 맵에 크기를 설정하는 것을 잊었습니다.

여전히 for 루프 내에 추가해야했습니다.

그래요. 그래도 여전히 문제가있는 것으로 보입니다. 스크롤바는 나타나지 않고 스크롤 상자의 크기를 조정하려고합니다 (두 패널 사이에 슬라이더가 있습니다. 하나는 스크롤 상자의 부모이고 다른 하나는 다른 구성 요소를 보유하고 있습니다) 아무 것도하지 않거나 (아무 것도 움직이지 않음) 슬라이더가 떨어져 나가게합니다 왼쪽의 화면은 응용 프로그램 창에서 모든 것을 숨 깁니다.

나는 firemonkey에 익숙하지 않기 때문에, 이것은 경쾌합니다. VCL에서이 작업을 쉽게 수행 할 수 있었지만 firemonkey의 "호평받는 힘"을 탐구하려고 노력하고 있습니다.