Autor Beitrag
Wolle92
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Di 03.06.08 17:37 
Hallo

Ich hab im Private-Teil meines Programms einen zweidimensionalen Array of TImage deklariert und wollte dann in der OnCreate des Forms alle diese Images erstellen und anordnen, da ich, faul wie ich bin, keine Lust habe 486 Images aufs Formular zu setzen und die dann alle in der Struktur stehen zu haben ;)

Hier mal der Kot:
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:
...

private
  images: array [1..27] of array [1..18] of TImage;

...

procedure TForm2.FormCreate(Sender: TObject);
var i, j: Integer;
begin
  for i := 1 to 27 do
  begin
    for j := 1 to 18 do
    begin
      images[i][j].Create(Form2);
      images[i][j].Width := 25;
      images[i][j].Height := 25;
      images[i][j].Top := (j * 25) - 25;
      images[i][j].Left := (i * 25) - 25;
      images[i][j].Canvas.FloodFill(0,0,RGB(random(256),random(256),random(256)),fsSurface);
    end;
  end;
end;


Wo kann der Fehler liegen?

_________________
1405006117752879898543142606244511569936384000000000.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 03.06.08 17:39 
Statt images[i][j].Create(Form2); muss es images[i][j] := TImage.Create(Form2); heißen.

_________________
We are, we were and will not be.
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Di 03.06.08 17:41 
:autsch: :autsch: :autsch: :autsch: :autsch: :autsch: :autsch:

Ach ja... Mein Gott, bin ich heut wieder mal hohl^^

_________________
1405006117752879898543142606244511569936384000000000.
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Di 03.06.08 17:45 
hm, aber irgendwie werden die net angezeigt... Oder zumindest nicht befüllt mit Farbe...

_________________
1405006117752879898543142606244511569936384000000000.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Di 03.06.08 17:49 
Du hast vergessen "Parent" zu setzen. ;)
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Di 03.06.08 17:52 
okay, das es jetzt immernoch nicht geht, liegt daran, das irgwendwie FloodFill bei mir nie will...
mit Canvas.Rectangel gehts nämlich

_________________
1405006117752879898543142606244511569936384000000000.
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Di 03.06.08 18:27 
okay, nächstes Problem...
Hab jetzt zwischen den einzelnen Images jweweils einen Pixel frei gelassen, weil da linien durch sollen...
Und jetzt will ich da aufs Form1.Canvas schwarze Linien zeichnen, aber das geht nicht...
Sprich, es kommen keinen Linien...
Woran kann das liegen?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.FormCreate(Sender: TObject);
var i, j: Integer;
begin
  for i := 1 to 25 do
  begin
    for j := 1 to 16 do
    begin
      images[i][j] := TImage.Create(Form1);
      images[i][j].Parent := Form1;
      images[i][j].Width := 30;
      images[i][j].Height := 30;
      images[i][j].Top := (j * 31) - 31;
      images[i][j].Left := (i * 31) - 31;
      images[i][j].Picture.LoadFromFile(ExtractFilePath(Application.ExeName) + '\images\free.bmp');
      Form1.Canvas.MoveTo(i * 31 - 31, j * 31 - 31);
      Form1.Canvas.LineTo(i * 31, j * 31);
    end;
  end;
end;

_________________
1405006117752879898543142606244511569936384000000000.


Zuletzt bearbeitet von Wolle92 am Di 03.06.08 18:53, insgesamt 1-mal bearbeitet
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Di 03.06.08 18:36 
user profile iconWolle92 hat folgendes geschrieben:
okay, nächstes Problem...


Schön - also eine neues Thema :P
Da kannste dann auch direkt die Code-TAGs nochmal üben ;)
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Di 03.06.08 18:53 
sei doch still... das ist die gleiche Procedure, also auch das gleiche thema...
So seh ich das ;)

_________________
1405006117752879898543142606244511569936384000000000.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Di 03.06.08 18:56 
user profile iconWolle92 hat folgendes geschrieben:
sei doch still... das ist die gleiche Procedure, also auch das gleiche thema...
So seh ich das ;)

Nope. Dein neues Problem hat nichts mit dem im Thread-Titel genannten zu tun. Daher neue Frage, neues Topic. ;)
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Di 03.06.08 18:57 
Nö, ich bin nicht still.

Das Thema heißt "EAccessViolation bei Create eines Image-Arrays", und nicht "Problem beim Zeichnen einer Linie auf dem Formular".
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Di 03.06.08 19:23 
jaja... schon gut, hasb problem acuh mittlerweile gelöst...

_________________
1405006117752879898543142606244511569936384000000000.