Board index » delphi » Invisible Control

Invisible Control

Hi,
I created a control by the code:

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

Image1.Picture.LoadFromFile('c:\delphi\images\icons\skyline.ico')
;
  Image1.left:=50;
  Image1.top:=50;
  Image1.width:=32;
  Image1.height:=32;
  Image1.BringToFront;
  Image1.visible:=true;
end;

Unfortunately the control is not seen.
What's wrong? Any help is highly appreciated.

Andrew

 

Re:Invisible Control


Quote
Andrew Wolfenburg <73670.1...@CompuServe.COM> wrote:
>Hi,
>I created a control by the code:
>procedure TForm1.Button1Click(Sender: TObject);
>begin
>  Image1:=TImage.Create(Form1);

>Image1.Picture.LoadFromFile('c:\delphi\images\icons\skyline.ico')
>;
>  Image1.left:=50;
>  Image1.top:=50;
>  Image1.width:=32;
>  Image1.height:=32;
>  Image1.BringToFront;
>  Image1.visible:=true;
>end;
>Unfortunately the control is not seen.
>What's wrong? Any help is highly appreciated.
>Andrew

You need to set the Parent property..

Rkr

Re:Invisible Control


You need to set the Parent property for it to show up.  Add this line:

Image1.Parent := Form1;

Andrew Wolfenburg <73670.1...@CompuServe.COM> wrote in article
<5cjou7$qp...@mhade.production.compuserve.com>...

Quote
> Hi,
> I created a control by the code:

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

> Image1.Picture.LoadFromFile('c:\delphi\images\icons\skyline.ico')
> ;
>   Image1.left:=50;
>   Image1.top:=50;
>   Image1.width:=32;
>   Image1.height:=32;
>   Image1.BringToFront;
>   Image1.visible:=true;
> end;

> Unfortunately the control is not seen.
> What's wrong? Any help is highly appreciated.

> Andrew

Re:Invisible Control


You need to set the Parent property for it to show up.  Add this line:

Image1.Parent := Form1;

Andrew Wolfenburg <73670.1...@CompuServe.COM> wrote in article
<5cjou7$qp...@mhade.production.compuserve.com>...

Quote
> Hi,
> I created a control by the code:

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

> Image1.Picture.LoadFromFile('c:\delphi\images\icons\skyline.ico')
> ;
>   Image1.left:=50;
>   Image1.top:=50;
>   Image1.width:=32;
>   Image1.height:=32;
>   Image1.BringToFront;
>   Image1.visible:=true;
> end;

> Unfortunately the control is not seen.
> What's wrong? Any help is highly appreciated.

> Andrew

Other Threads