Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-09

TImage at runtime

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

S. M. Falcao

Hello,

I'am starting with Lazarus and after one week project I decided to try a bit challenging one, so I've decided to create a chess GUI. I've created a not so smart group of TImages at design time and loaded images corresponding white and black squares what worked accordingly, ofc, after my short test, I've decided try to create them at runtime with the following code:

var
   Form1: TForm1;
   Square_a : array [1..8] of TImage;

.
.

procedure TForm1.FormCreate(Sender: TObject);
begin
   Square_a[1] := TImage.Create (Self);
   Square_a[1].Enabled:=True;
   Square_a[1].Visible:=True;
   Square_a[1].AutoSize:=False;
   Square_a[1].Left:=0;
   Square_a[1].Top:=300;
   Square_a[1].Height:=50;
   Square_a[1].Width:=50;
   Square_a[1].Name:='a1';
   Square_a[1].Picture.LoadFromFile('white.jpg');
end;

For my surprise I could not manage to make white.jpg visible. Maybe is an obviuos mistake from my side, I am checking some docs about TImage usage, if someone already knows what is wrong with this code would save me some time.

Thanks a lot

Reply by email

Mattias Gaertner
to S. M. Falcao
Show quoted text 28 lines
Hello, I'am starting with Lazarus and after one week project I decided to try a bit challenging one, so I've decided to create a chess GUI. I've created a not so smart group of TImages at design time and loaded images corresponding white and black squares what worked accordingly, ofc, after my short test, I've decided try to create them at runtime with the following code: var Form1: TForm1; Square_a : array [1..8] of TImage; . . procedure TForm1.FormCreate(Sender: TObject); begin Square_a[1] := TImage.Create (Self); Square_a[1].Enabled:=True; Square_a[1].Visible:=True; Square_a[1].AutoSize:=False; Square_a[1].Left:=0; Square_a[1].Top:=300; Square_a[1].Height:=50; Square_a[1].Width:=50; Square_a[1].Name:='a1'; Square_a[1].Picture.LoadFromFile('white.jpg');
Square_a[1].Parent:=Self;
Show quoted text 6 lines
end; For my surprise I could not manage to make white.jpg visible. Maybe is an obviuos mistake from my side, I am checking some docs about TImage usage, if someone already knows what is wrong with this code would save me some time.

Mattias

Reply by email

S. M. Falcao
to Mattias Gaertner
Mattias Gaertner wrote 47 lines
On Thu, 16 Sep 2010 17:47:49 -0300 "S. M. Falcao" wrote: > Hello, > > I'am starting with Lazarus and after one week project I decided to try a > bit challenging one, so I've decided to create a chess GUI. I've > created a not so smart group of TImages at design time and loaded images > corresponding white and black squares what worked accordingly, ofc, > after my short test, I've decided try to create them at runtime with the > following code: > > var > Form1: TForm1; > Square_a : array [1..8] of TImage; > > . > . > > procedure TForm1.FormCreate(Sender: TObject); > begin > Square_a[1] := TImage.Create (Self); > Square_a[1].Enabled:=True; > Square_a[1].Visible:=True; > Square_a[1].AutoSize:=False; > Square_a[1].Left:=0; > Square_a[1].Top:=300; > Square_a[1].Height:=50; > Square_a[1].Width:=50; > Square_a[1].Name:='a1'; > Square_a[1].Picture.LoadFromFile('white.jpg'); Square_a[1].Parent:=Self; > end; > > For my surprise I could not manage to make white.jpg visible. Maybe is > an obviuos mistake from my side, I am checking some docs about TImage > usage, if someone already knows what is wrong with this code would save > me some time. Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Hello Mattias,

solved

thanks a lot.

Reply by email