Autor Beitrag
Niko S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 566
Erhaltene Danke: 10

Win 7, Ubuntu
Lazarus, Turbo Delphi, Delphu 7 PE
BeitragVerfasst: Sa 25.08.07 23:10 
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:
var
  MyImage: array[0..300] of TImage;
...
procedure TFrame2.getTexture();
var
  i,t,l,q:Integer;
begin
  t := 0;
  l := 0;
  q := 0;
  for i := 1 to 300 do
  begin;
    inc(q);
    MyImage[i] := TImage.Create(Frame2);
    MyImage[i].width := 32;
    MyImage[i].Height := 32;
    MyImage[i].Left := l;
    MyImage[i].Top := t;
    MyImage[i].Visible := True;
    MyImage[i].Picture.BitMap.LoadFromFile(ExtractFilePath(Application.ExeName)+'gfx\map\70.bmp');
    label1.Caption := Format('%d/%d/%d/%d/%d',[q,MyImage[i].Left,MyImage[i].Top,MyImage[i].width,MyImage[i].Height]);
    t := t+32;
    if not (l = (480-32)) then
    begin
      if (t >= (640-32)) then begin t := 0; l := l+32; end;
    end;
  end;
end;


Tja so schaut' sie aus, meine kleine Funktion und ist in einem Frame drinne ... Problem:
Es funktioniert nicht.
Ich sehe im endeffekt nichts.
Das Bild ist richtig, bzw. der Pfad.
Was mache ich falsch?
Killian2004
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 72

Vista Business x64
Delphi 7 Ent. RAD Studio 2009
BeitragVerfasst: Sa 25.08.07 23:32 
Hm, der Code ist korrekt, aber du übergibst dem Image kein Parent-Objekt. Daher wird das Bild nirgends angezeigt.

Füge folgendes hinzu:
ausblenden Delphi-Quelltext
1:
MyImage[i].Parent := Frame2;					



Das sollte das Sichtbarkeitsproblem lösen.
Als Tipp: Ein Array Of TImage mit 301 Feldern ist unelegant, besser wäre ein dynamisches Array, dem du die jeweils notwendige Länge übergibst.
(Oder arbeitest du in diesem Beispiel immer mit exakt 301 Bilder?)

mfG, Killian

_________________
Die Antwort ist 17, aber wie lautet die Frage?
Niko S. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 566
Erhaltene Danke: 10

Win 7, Ubuntu
Lazarus, Turbo Delphi, Delphu 7 PE
BeitragVerfasst: Sa 25.08.07 23:38 
Danke, Dass hat mein Problem gelöst.

Und ja, ich Arbeite mit exact 300 Bildern.
Ich hab da nur noch ein paar kleinigkeiten falsch angegeben.
0..299 müsste da stehen.