Results 1 to 5 of 5

Thread: TImage doesn't show

  1. #1

    TImage doesn't show

    I'm having trouble displaying a TImage component on a scrollbox. I'm attempting to create a TImage component on a scrollbox, initialize it, load in an image from a file, and finally display it on the scrollbox. I can happily display the image when loading it at design-time or runtime, but only on a TImage which was created at design-time, not runtime --- so I know that there isn't anything wrong with the image itself. I can't get a hint to appear either, so it suggests the control isn't being displayed at all.

    This is the code I'm using:
    [pascal]
    var
    Image: TImage;
    {...}
    //create the image and initialize it
    Image:=TImage.Create(ScrollBox);
    Image.Visible:=False;
    Image.Stretch:=True;
    Image.ShowHint:=True;
    Image.Hint:='Bleh';
    Image.Left:=0;
    Image.Top:=0;
    Image.Width:=100;
    Image.Height:=100;
    {...}
    //load in an image from a file
    Image.Picture.LoadFromFile('C:\Bleh.png');
    {...}
    //display the image on the scrollbox
    Image.Visible:=True;
    [/pascal]
    As far as I know, that should work. Any ideas as to what's wrong? It feels like I'm doing something unbelievably stupid here but I don't know what...

    Cheers for any help.

  2. #2

    TImage doesn't show

    try Image.parent := ScrollBox1

  3. #3

    TImage doesn't show

    Code:
    procedure TForm1.Button1Click(Sender: TObject);
    var
     i,
     j: Integer;
    
     Count: Integer;
    
     Image: TImage;
    
     GPI: TGPI;
    
    begin
      Count := 0;
      for j:=1 to NumGPI div 10 do
        for i:=1 to 5 do
          if Count < NumGPI then
            Begin
              GPI &#58;= TGPI.Create;
              GPI.LoadGPI&#40;&#123;GPI&#91;Count&#93;.FileName&#125;GPIPath + FileList&#91;Count&#93;&#41;;
    
              Image &#58;= TImage.Create&#40;ScrollBox1&#41;;
                with Image do
                  Begin
                    Parent &#58;= ScrollBox1;
    
                    Left &#58;= &#40;8 + &#40;i *&#40;128 + 16&#41;&#41;&#41; - &#40;128+16+4&#41;;
                    Top  &#58;= &#40;8 + &#40;j *&#40;128 + 16&#41;&#41;&#41; - &#40;128+16+4&#41;;
    
                    Width &#58;= 128;
                    Height &#58;= 128;
    
                    Stretch &#58;= True;
    
                    Tag &#58;= Count;
    
                    Visible &#58;= True;
    
                    Picture.Bitmap &#58;= GPI.TGA;
                  end;
                GPI.Free;
    
              Inc&#40;Count&#41;;
            end;
    end;

    give that a go

  4. #4

    TImage doesn't show

    Heh, so simple...cheers it works!

  5. #5

    TImage doesn't show

    good good

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •