Autor Beitrag
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 19.06.05 17:00 
hallo, mir war grad danach, den matrix code in form von labels in ganze billiger form vom formular rieseln zu lassen, nun dachte ich daran, dass ich bei jedem timer tick eine neue reihe erstelle und dann alles um 12 pixel nach unten verschiebe, komischerweise (oder auch net) bekomme ich einen Fehler (screenshot anhang)
hier code:
ausblenden volle Höhe 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:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Matrix: array of array of TLabel;
  count: integer = 0;

implementation

{$R *.dfm}  

procedure TForm1.Timer1Timer(Sender: TObject);
var
  i, j, k: integer;
begin
  count := count + 1;
  setlength(Matrix, 50, count);
  for i := 0 to 49 do
    begin
      Matrix[i, count] := TLabel.Create(self);
      with Matrix[i, count] do
        begin
          parent := Form1;
          left := i * 10;
          top := 0;
          font.name := 'mcode15';
          font.size := 12;
          font.color := clgreen;
          caption := chr(random(26) + 65);
        end;
    end;
  for j := 0 to 49 do
    for k := 0 to count do
      Matrix[j, k].top := Matrix[i, k].top + 12;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  setlength(Matrix, 0, 0);
end;

procedure TForm1.FormDestroy(Sender: TObject);
var
  i, j: integer;
begin
  for i := 0 to 49 do
    for j := 0 to count do
      Matrix[i, j].free;
end;

end.
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: So 19.06.05 18:49 
user profile iconF34r0fTh3D4rk hat folgendes geschrieben:
ausblenden Delphi-Quelltext
 
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
{ ... }
procedure TForm1.Timer1Timer(Sender: TObject);
var
  i, j, k: integer;
begin
  count := count + 1;
  setlength(Matrix, 50, count);
  for i := 0 to 49 do
    begin // 0, 1
      Matrix[i, count] := TLabel.Create(self);
      with Matrix[i, count] do
        begin
          parent := Form1;
          left := i * 10;
          top := 0;
          font.name := 'mcode15';
          font.size := 12;
          font.color := clgreen;
          caption := chr(random(26) + 65);
        end;
    end;
  for j := 0 to 49 do
    for k := 0 to count do
//           0, 0
      Matrix[j, k].top := Matrix[i, k].top + 12;
end;
{...}


das müsste es sein... Matrix[0, 0] = nil, und nil.top ist bäh. ;)

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
F34r0fTh3D4rk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mo 20.06.05 11:53 
i, count ist [0, 1], da könnte der fehler liegen :idea:

ändert auch nichts, wenn ich überall bei 0 oder 1 anfange, bei 0 stimmt schon