Autor Beitrag
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Mo 23.03.15 23:52 
Ich kann es mir zwar nicht erklären, aber dieses Mal hat es ohne Fehlermeldung funktioniert und dann auch das Programm korrekt ausgeführt ?!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 24.03.15 00:00 
Moin!

user profile iconNini hat folgendes geschrieben Zum zitierten Posting springen:
Ich kann es mir zwar nicht erklären, aber dieses Mal hat es ohne Fehlermeldung funktioniert
:zustimm: Tja, war wohl Schluckauf... :lol:

user profile iconNini hat folgendes geschrieben Zum zitierten Posting springen:
und dann auch das Programm korrekt ausgeführt ?!
Soll heißen, wenn du auf den Button klickst, wird ein neues Shape erstellt? ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Di 24.03.15 00:02 
genau, da kommt nen neues shape oben links :)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 24.03.15 00:07 
Moin!

Perfekt! :zustimm:

Nächster Schritt: wieder zum Game of Life Projekt wechseln und alle Shapes vom Formular löschen. :hair: Keine Panik, die legen wir gleich alle wieder beim Programmstart automatisch an. ;)

Dazu machst du einen Doppelklick auf dem Formularhintergrund, es sollte ein neuer Handler angelegt werden, und zwar für das Ereignis FormCreate. :idea: Da müssen wir nun den Code reinschreiben, der die Shapes erzeugt. Wie man ein Shape erzeugt hast du nun gesehen und getestet. Dann mach doch mal einen (Code-)Vorschlag, wie man das auf die Menge Shapes "aufbohrt", die wir brauchen. :lupe: (ich würde als Tipp mal so sagen, du brauchst da ne Schleife, so ähnlich wie beim btnLesenClick :think:)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Di 24.03.15 00:15 
mein vorschlag wäre das:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.FormCreate(Sender: TObject);
var i,j,x : integer;
    shape : TShape;
begin
  x := strtoint(edit1.text);
  for j := 1 to x do
   for i := 1 to x do begin
    Shape := TShape.Create(Self); // Shape-Objekt erzeugen, als Eigentümer das Formular (=Self) angeben
    Shape.Parent := Self; // das neue Shape soll auf dem Formular (=Self) angezeigt werden
    Shape.Name := 'Shape'+i; // Name der Komponente
    Shape.Left := 8+i*25// 8 Pixel vom linken Rand
    Shape.Top := 8+i*25// 8 Pixel vom oberen Rand
    Shape.Width := 25// 25 Pixel breit
    Shape.Height := 25// 25 Pixel hoch
  end;
end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 24.03.15 00:22 
Moin!

Gar nicht übel! :zustimm:

Allerdings muss ich dir leider den Zahn mit dem Edit-Feld und der Eingabe der Feldgröße zur Laufzeit wieder ziehen :? das geht leider nicht ganz so einfach (also es geht schon, aber eben etwas anders). :nixweiss:

Du musst in diesem Ansatz einfach N für die Kantenlänge verwenden, also die Konstante, die du im Programm ganz oben deklariert hast. :idea: Und dann noch beim Namen des Shapes beachten, dass dieser sowohl eindeutig, als auch der Konvention ("Reihenfolge") entspricht, wie bei den manuell angelegten Shapes (im Moment erzeugst du Shapes, die mehrfach den gleichen Namen haben :shock:).

Also, nächster Versuch. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Di 24.03.15 00:27 
meine nächste Variante:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TForm1.FormCreate(Sender: TObject);
var i,j,snr : integer;
    shape : TShape;
begin
  for j := 0 to N-1 do
   for i := 0 to N-1 do begin
    Shape := TShape.Create(Self); // Shape-Objekt erzeugen, als Eigentümer das Formular (=Self) angeben
    Shape.Parent := Self; // das neue Shape soll auf dem Formular (=Self) angezeigt werden
    snr := x +y *N +1;
    Shape := TShape(FindComponent('Shape' +IntToStr(snr)));
    //Shape.Name := 'Shape'+inttostr(i); // Name der Komponente
    Shape.Left := 8+i*25// 8 Pixel vom linken Rand
    Shape.Top := 8+i*25// 8 Pixel vom oberen Rand
    Shape.Width := 25// 25 Pixel breit
    Shape.Height := 25// 25 Pixel hoch
  end;
end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 24.03.15 00:32 
Moin!

Schon besser. ;)

Aaaaber... :P

ausblenden Delphi-Quelltext
1:
snr := x +y *N +1;					
Damit berechnest du (völlig korrekt!) die Shape-Nr. :zustimm:

ausblenden Delphi-Quelltext
1:
Shape := TShape(FindComponent('Shape' +IntToStr(snr)));					
Statt diese zu verwenden, versuchst du ein bereits vorhandenes Shape zu finden :lupe: :?!?: (was es logischerweise nicht gibt!)

ausblenden Delphi-Quelltext
1:
//Shape.Name := 'Shape'+inttostr(i); // Name der Komponente					
...und kommentierst den (fast korrekten) Code, der das was du brauchst, tut, aus. :eyes:

Also: noch ein Versuch! :D

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Di 24.03.15 00:34 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.FormCreate(Sender: TObject);
var i,j,snr : integer;
    shape : TShape;
begin
  for j := 0 to N-1 do
   for i := 0 to N-1 do begin
    Shape := TShape.Create(Self); // Shape-Objekt erzeugen, als Eigentümer das Formular (=Self) angeben
    Shape.Parent := Self; // das neue Shape soll auf dem Formular (=Self) angezeigt werden
    snr := x +y *N +1;
    Shape.Name := 'Shape'+inttostr(snr); // Name der Komponente
    Shape.Left := 8+i*25// 8 Pixel vom linken Rand
    Shape.Top := 8+i*25// 8 Pixel vom oberen Rand
    Shape.Width := 25// 25 Pixel breit
    Shape.Height := 25// 25 Pixel hoch
  end;
end;


so das dürfte jetzt stimmen
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 24.03.15 00:39 
Moin!

user profile iconNini hat folgendes geschrieben Zum zitierten Posting springen:
so das dürfte jetzt stimmen
Jap, sieht gut aus! :zustimm: Schon ausprobiert? ;) Was fehlt noch (funktional)? :P

cu
Narses

PS: Ah, kleiner Bug ist noch drin... :zwinker:

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Di 24.03.15 00:43 
musste noch x und y als integer deklarieren aber was ich gegen die debuggernachricht machen soll weiß ich gar nicht ... :(
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 24.03.15 00:53 
Moin!

user profile iconNini hat folgendes geschrieben Zum zitierten Posting springen:
musste noch x und y als integer deklarieren
Jap, genau da ist noch was im Argen... ;) Tipp: Entweder du verwendest x und y oder du verwendet i und j, beides "mischen" ist nicht so schlau. :zwinker:

user profile iconNini hat folgendes geschrieben Zum zitierten Posting springen:
aber was ich gegen die debuggernachricht machen soll weiß ich gar nicht ... :(
Dazu müsstest du diese mal zeigen. :lupe: :les:

Aber korrigier erstmal noch das Index-Problem in den Schleifen/Deklaration, vielleicht ist der andere Fehler dann schon weg. :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Di 24.03.15 00:56 
ja es funktioniert *_* das war wohl noch mein fehler :)
hab jetzt beim programm start ein 5x5-Raster
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 24.03.15 00:58 
Moin!

Dann zeig nochmal kurz den Code (FormCreate reicht). :les:

Und, was "fehlt" jetzt noch (funktional)? :D

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Di 24.03.15 01:02 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.FormCreate(Sender: TObject);
var snr,y,x : integer;
    shape : TShape;
begin
  for y := 0 to N-1 do
   for x := 0 to N-1 do begin
    Shape := TShape.Create(Self); // Shape-Objekt erzeugen, als Eigentümer das Formular (=Self) angeben
    Shape.Parent := Self; // das neue Shape soll auf dem Formular (=Self) angezeigt werden
    snr := x +y *N +1;
    Shape.Name := 'Shape'+inttostr(snr); // Name der Komponente
    Shape.Left := 8+x*25// 8 Pixel vom linken Rand
    Shape.Top := 8+y*25// 8 Pixel vom oberen Rand
    Shape.Width := 25// 25 Pixel breit
    Shape.Height := 25// 25 Pixel hoch
  end;
end;


irgendwas, dass ich die felder wieder färben kann fehlt noch und dass ich N irgendwie ändern kann im programm
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 24.03.15 01:10 
Moin!

Ja, der Code sieht jetzt gut aus. :zustimm:

user profile iconNini hat folgendes geschrieben Zum zitierten Posting springen:
irgendwas, dass ich die felder wieder färben kann fehlt noch
Genau! :D Da war doch noch so eine auskommentierte Zeile in der Demo... :lupe: wozu mag die wohl gut gewesen sein... :gruebel:

user profile iconNini hat folgendes geschrieben Zum zitierten Posting springen:
und dass ich N irgendwie ändern kann im programm
Tja, grundsätzlich geht sowas zwar, aber nicht mit diesem Ansatz. :nixweiss: Dazu müsste man das Programm etwas anders aufziehen. In dieser Version musst du N im Quelltext ändern und dann neu kompilieren. :(

Auf der anderen Seite: das ist natürlich so gesehen eine (die nächste?) Herausforderung? :zwinker: Wenn du möchtest, können wir uns dieses Problems später nochmal annehmen. ;)

Jetzt kriegen wir das aber erstmal überhaupt wieder ans Laufen. :P

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Di 24.03.15 01:27 
Shape.OnMouseDown := Shape1MouseDown; weist ja die Methode zu, also für das shape dann das was in prozedur TForm1.Shape1MouseDown steht oder?

kann ich das dann einfach unten noch ranschreiben?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 24.03.15 16:39 
Moin!

Jap, genau so. :zustimm: Klappt? ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Di 24.03.15 17:05 
ne, ich bekomm da ne fehlermeldung:
wrong number of parametersspecified for call to "Shape1MouseDown"
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 24.03.15 17:20 
Moin!

OK, laut dem Beitrag hier muss man bei Lazarus noch ein "@" vor den Methodennamen setzen (sehr merkwürdig :?), also:
ausblenden Delphi-Quelltext
1:
Shape.OnMouseDown := @Shape1MouseDown;					

Geht das?

cu
Narses

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