Board index » delphi » How do you create Image in runtime?

How do you create Image in runtime?

How do you create TImage Runtime?

I've tried this, but it doesn't seems to work:

procedure TForm1.Button1Click(Sender: TObject);
var
   Image1: TImage;
begin
    Image1:= TImage.Create(Form1);
end;

Couldt anyone tell me why, and tell me what to do else?????

Thanks

Peter

 

Re:How do you create Image in runtime?


--
Andreas Klein
eMail: a-k...@metronet.de

Peter Jacobsen schrieb in Nachricht <355C52C2.D6968...@vip.{*word*104}city.dk>...

Quote
>How do you create TImage Runtime?

>I've tried this, but it doesn't seems to work:

>procedure TForm1.Button1Click(Sender: TObject);
>var
>   Image1: TImage;
>begin
>    Image1:= TImage.Create(Form1);

        Image1.Parent := Form1;

(* that should work *)

Quote
>end;

>Couldt anyone tell me why, and tell me what to do else?????

>Thanks

>Peter

Re:How do you create Image in runtime?


Quote
Peter Jacobsen wrote:

> How do you create TImage Runtime?

> I've tried this, but it doesn't seems to work:

> procedure TForm1.Button1Click(Sender: TObject);
> var
>    Image1: TImage;
> begin
>     Image1:= TImage.Create(Form1);
> end;

> Couldt anyone tell me why, and tell me what to do else?????

> Thanks

> Peter

 Try also adding this:

  Image1.Parent := Form1;
  Image1.Visible := True;

Hope that helps!

 Rkr

--
                   \|||/
                   /'^'\
                  ( 0 0 )
--------------oOOO--(_)--OOOo--------------
. Reid Roman                              .
. Delphi Programmer / Analyst             .
. TVisualBasic:=class(None);              .
. May the Source be With You              .
-------------------------------------------
. Auto-By-Tel (http://www.autobytel.com)  .
. Irvine, CA U.S.A                        .
. E-Mail : rkroman (at) pacbell (dot) net .
. or reidr (at) autobytel (dot) com       .
-------------------------------------------

Re:How do you create Image in runtime?


Peter,

You also need to set some other items when you create the TImage:

var
   Image1: TImage;
begin
   Image1 := TImage.Create(Self);
   with Image1 do begin
      Parent := Self;   // Makes it show on form
      Top := 100;
      Left := 100;
      Width := 100;
      Height := 100;
      // Draw on or load a picture here
   end;
end;

HTH

Ken
--
Ken White
kwh...@westelcom.com

Clipper Functions for Delphi
http://members.aol.com/clipfunc/

Quote
Peter Jacobsen wrote:

> How do you create TImage Runtime?

> I've tried this, but it doesn't seems to work:

> procedure TForm1.Button1Click(Sender: TObject);
> var
>    Image1: TImage;
> begin
>     Image1:= TImage.Create(Form1);
> end;

> Couldt anyone tell me why, and tell me what to do else?????

> Thanks

> Peter

Other Threads