Board index » delphi » Create image at runtime

Create image at runtime

I try to make a programme in which I create a TImage at runtime.
The reason for this is: I want to be able to create an array of a rather
large number (e.g. 24) of such images.
I am afraid that I don't really know what I am doing, because what I made
compiles and runs without any problem, but I don't see any result.
This is what I typed:

----------------------------
....
Var im: TImage;
....

procedure TForm1.FormCreate(Sender: TObject);
begin
  im:=timage.create(form1);
  with im do begin
    left:=2; top:=2; width:=20;height:=20; show;
    showhint:=true; hint:='hoi';
    canvas.rectangle(10,10,50,50);
  end;
.....
-------------------------------

The hint and the rectangle are just to try to see anything; but I don't see
anything.
What do I do wrong?

Niko Roorda

 

Re:Create image at runtime


Quote
"Niko" wrote:
> I try to make a programme in which I create a TImage at runtime.
> The reason for this is: I want to be able to create an array of a
rather
> large number (e.g. 24) of such images.
> I am afraid that I don't really know what I am doing, because what I
made
> compiles and runs without any problem, but I don't see any result.
> <snip>
> What do I do wrong?

You need to set the TImage's "Parent" property too.
Eg: YourImage.Parent := Form1;

-ThomasN

Re:Create image at runtime


Quote
In article <9q7137$a6...@reader07.wxs.nl>, "Niko" <n...@n.net> writes:
>The hint and the rectangle are just to try to see anything; but I don't see
>anything.
>What do I do wrong?

You haven't set the Parent of the image. The Parent is where the object gets
its windows messages from, including those to show itself, and to position
itself relative to. Use the form (or Self) to start with.

Note that TControl.SetBounds sets the size and position in one statement.

Alan Lloyd
alangll...@aol.com

Other Threads