Autor Beitrag
Passi077
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 125

Win XP
D7 Pers
BeitragVerfasst: So 17.10.04 20:04 
Hi,

ich erstelle zur Laufzeit ein paar Image Boxen und möchte diesen nun eine Eigenschaft zuweisen.

Da ich eigentlich nicht weiß, wie viele Images erstellt werden, weise ich diese Eigenschaften mit FindComponent zu.

Leider funktioniert mein Code irgendwie nicht.


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:
27:
28:
procedure TForm1.FormCreate(Sender: TObject);
var
newborder: timage;
anzahl, i: integer;
begin
  anzahl := 3;

  for i := 1 to anzahl do begin

  newborder := timage.Create(owner);
  newborder.Parent := Self;
  newborder.name :='colunten' + inttostr(i);
  newborder.Top := i * 20;
  newborder.left := i * 20;
  newborder.Width := 15;
  newborder.height := 15;

  end;

end;

procedure TForm1.Button1Click(Sender: TObject);
var z: integer;
begin
  for z := 1 to 3 do begin
    (FindComponent('colunten'+IntToStr(z)) as Timage).Picture.LoadFromFile('C:\Program files\Coding\Borland Delphi7\Projects\Sprites5 - Bewegung II\images\hin1.bmp');
  end;
end;


Die Images werden auf jeden Fall richtig erstellt, das habe ich ausprobiert in dem ich ihnen gleich noch ein Image zum Laden gegeben habe.

Aber die nachträgliche Zuweisung eines Wertes funktioniert leider nicht.

Was mache ich da falsch?

Danke + Grüße
Passi
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: So 17.10.04 20:15 
Hallo

Zitat:

newborder := timage.Create(owner);

probier mal statt "owner" Form1 oder self zuschreiben.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
kachel81
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63



BeitragVerfasst: Di 19.10.04 09:41 
Versuch die Iteration über die Controls:

ausblenden Delphi-Quelltext
1:
2:
3:
for i := 0 to ControlCount - 1 do
  if Controls[i] is TImage then
    TImage(Controls[i]).Picture....