Autor Beitrag
GR-Thunderstorm
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Mi 21.02.07 16:14 
Hi Leutz!
Ich wollte in einem Array mehrere Bilder einbinden:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
var ground: array[1..33] of TImage;

procedure TForm1.FormActivate(Sender: TObject);
var a:integer;
begin
for a:=1 to 33 do
begin
ground[a].Create(self);
ground[a].Left:=3;
ground[a].Width:=1;
ground[a].Height:=1;
ground[a].Visible:=true;
ground[a].Enabled:=true;
ground[a].Picture:=boden1.Picture; //LoadFromFile(ExtractFilepath(paramstr(0)) + 'Texturen\Betonrasen.bmp');
ground[a].AutoSize:=true;
ground[a].Top:=30;
ground[a].Left:=(a-1)*ground[a].Width+ground[a].Width;
ground[a].Parent:=form1;
end;
end;


Kann hier jemand einen Fehler finden?
Jedes mal wenn ich das Prog starten will hängt es sich auf... :(

Danke schonmal!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 21.02.07 16:22 
Moin!

Abgesehen davon, dass ich FormCreate (wird garantiert nur einmal aufgerufen) und nicht FormActivate (könnte auch mehrfach aufgerufen werden!) nehmen würde, kann ich auf den ersten Blick nix falsches sehen... :?

cu
Narses

//EDIT: :autsch: ja klar, TImage.Create... :oops:

_________________
There are 10 types of people - those who understand binary and those who don´t.


Zuletzt bearbeitet von Narses am Mi 21.02.07 22:49, insgesamt 2-mal bearbeitet
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Mi 21.02.07 17:40 
Thx... daran lag es nicht. ^^
Hab den Fehler gefunden:

ground[a].Create(self); <-- :(
ground[a]:=TImage.Create(self); <-- :)
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Mi 21.02.07 18:03 
[quote="[user]
ground[a].Picture:=boden1.Picture; //LoadFromFile(ExtractFilepath(paramstr(0)) + 'Texturen\Betonrasen.bmp');
[/Delphi]

Ist das beabsichtigt, oder wäre da ein
ausblenden Delphi-Quelltext
1:
ground[a].Picture.Assign(Boden1.Picture);					

zutreffender?

Gruß
alias5000

_________________
Programmers never die, they just GOSUB without RETURN
GR-Thunderstorm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 206



BeitragVerfasst: Mi 21.02.07 20:37 
user profile iconalias5000 hat folgendes geschrieben:
[quote="[user]
ground[a].Picture:=boden1.Picture; //LoadFromFile(ExtractFilepath(paramstr(0)) + 'Texturen\Betonrasen.bmp');
[/Delphi]

Ist das beabsichtigt, oder wäre da ein
ausblenden Delphi-Quelltext
1:
ground[a].Picture.Assign(Boden1.Picture);					

zutreffender?

Gruß
alias5000


Hmm mit .picture:=.picture gehts aber auch...

Aber jetzt ein weiteres Prob:
Ich will in einem Frame auf die selbe Art und Weise ein paar Bilder erstellen..

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
Frame:

public
     procedure weap;

procedure TFrame3.weap;
var a:integer;
begin
for a:=1 to 8 do
begin
weaps[a]:=TImage.Create(self);
weaps[a].Picture.LoadFromFile(ExtractFilepath(paramstr(0)) + 'Bilder\Hud\'+inttostr(a)+'.bmp');
weaps[a].Left:=3;
weaps[a].Top:=7;
weaps[a].Visible:=true;
weaps[a].Enabled:=true;
weaps[a].AutoSize:=true;
weaps[a].Left:=(a-1)*weaps[a].Width+3;
if a > 4 then
begin
weaps[a].Picture.LoadFromFile(ExtractFilepath(paramstr(0)) + 'Bilder\Hud\'+inttostr(a-4)+'.bmp');
weaps[a].Top:=56;
weaps[a].Left:=(a-5)*weaps[a].Width+3;
end;
weaps[a].Parent:=Form1;
end;


In meiner Unit1 habe ich dementsprechend den Befehl "Frame31.weap;".

Leider hängt sich das Prog hier wieder auf. :(

Mir ist auch rätselhaft, wieso ich bei "Parent" nichts anderes schreiben kann als Form1...