Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Delphi 2.0 TImage help needed please!!

I'm trying to create a TImage component at run-time but cannot get the image to display. I have the following code in a button.onClick event:

ImageTest := TImage.Create(Nil);
ImageTest.Stretch := True;
ImageTest.Height := 33;
ImageTest.Left := 80;
ImageTest.Width := 33;
ImageTest.Top := 16;
ImageTest.Picture.LoadFromFile ('BlueLace16.BMP');
ImageTest.Show;

The code compiles and runs ok but the image does not show. The file is in the current directory and is in bitmap format. Can someone please put me straight?

Any help greatly appreciated.

Jimi

Comments

  • zibadianzibadian Member Posts: 6,349
    : I'm trying to create a TImage component at run-time but cannot get the image to display. I have the following code in a button.onClick event:
    :
    : ImageTest := TImage.Create([red]Nil[/red]);
    : ImageTest.Stretch := True;
    : ImageTest.Height := 33;
    : ImageTest.Left := 80;
    : ImageTest.Width := 33;
    : ImageTest.Top := 16;
    : ImageTest.Picture.LoadFromFile ('BlueLace16.BMP');
    : ImageTest.Show;
    :
    : The code compiles and runs ok but the image does not show. The file is in the current directory and is in bitmap format. Can someone please put me straight?
    :
    : Any help greatly appreciated.
    :
    : Jimi
    :
    First you need to enter the name of the owner as the parameter of the image. This is usually the form on which it is placed. Secondly, you need to set the Parent to the control on which it is placed. I.e. if you want the image to be placed on Panel1 then add this line:
    [code]
    ImageText.Parent := Panel1;
    [/code]
    You don't need to call the Show() method, because that is handled automatically after you set the Parent.
  • Jimi HendrixJimi Hendrix Member Posts: 9
    : : I'm trying to create a TImage component at run-time but cannot get the image to display. I have the following code in a button.onClick event:
    : :
    : : ImageTest := TImage.Create([red]Nil[/red]);
    : : ImageTest.Stretch := True;
    : : ImageTest.Height := 33;
    : : ImageTest.Left := 80;
    : : ImageTest.Width := 33;
    : : ImageTest.Top := 16;
    : : ImageTest.Picture.LoadFromFile ('BlueLace16.BMP');
    : : ImageTest.Show;
    : :
    : : The code compiles and runs ok but the image does not show. The file is in the current directory and is in bitmap format. Can someone please put me straight?
    : :
    : : Any help greatly appreciated.
    : :
    : : Jimi
    : :
    : First you need to enter the name of the owner as the parameter of the image. This is usually the form on which it is placed. Secondly, you need to set the Parent to the control on which it is placed. I.e. if you want the image to be placed on Panel1 then add this line:
    : [code]
    : ImageText.Parent := Panel1;
    : [/code]
    : You don't need to call the Show() method, because that is handled automatically after you set the Parent.
    :

    You are a star zibadian! Many thanks for your help.
    Jimi
Sign In or Register to comment.