Autor Beitrag
thaflo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Zeta, Mandrake 9.1,Windoof XP
DELPHI 5
BeitragVerfasst: Sa 29.05.04 18:03 
Hallo!

ich habe folgenden code, wo ich immer eine exception bekomme.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure CreateShapes(var s_difficulty:short);
var loop:Short;
var s_leftPos:Short;
begin
    player_shapes[1]:=TShape.create(self); {undefinierter bezeichner self als meldung, wenn ich hier fmMain.fMain eingebe, bekomme ich die exception}

    for loop:=0 to s_difficulty do begin

         with player_shapes[loop] do begin
              player_shapes[loop].SetBounds(s_leftPos,50,80,20);
              s_leftPos:= s_leftPos+100;
              parent:=fmMain.fMain;
         end;
    end;
end;


danke für aussagekräftige hilfe für einen anfänger,
florian


Moderiert von user profile iconPeter Lustig: Code- durch Delphi-Tags ersetzt.

_________________
Jeder braucht die Zeit, die Zeit zum Lernen, man kommt nicht auf die Welt und sieht die Dinge wie sie sind....(onkelz)
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Sa 29.05.04 18:34 
Hallo,

da Deine procedure zu keiner Form gehört, steht der Parameter Self auch nicht zur Verfügung. Entweder Du übergibst diesen als Proceduerparameter oder Du benutzt die gleiche Angabe, die Du dem Parameter parent zuweist.

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
thaflo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Zeta, Mandrake 9.1,Windoof XP
DELPHI 5
BeitragVerfasst: Sa 29.05.04 18:44 
ja, danke für die hilfe, aber ich brauche mehr infos oder beispiele, da ich wirklich neu bin (von c++ her gekommen).wie könnte ich mein problem am Besten lösen?

florian

_________________
Jeder braucht die Zeit, die Zeit zum Lernen, man kommt nicht auf die Welt und sieht die Dinge wie sie sind....(onkelz)
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Di 01.06.04 09:01 
Hallo,

zeige einmal den Code, in dem Du die Procedure aufrufst. Wie heisst das dazugehörige Formular?

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
thaflo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Zeta, Mandrake 9.1,Windoof XP
DELPHI 5
BeitragVerfasst: Mi 02.06.04 11:55 
Hallo!

fMain heißt die Form.
und ich möchte einfach je nach benutzerangaben 3-6 felder auf der fom platzieren. das platzieren ist kein problem, nur das erstellen...
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure CreateShapes;
var loop:integer;
begin
    for loop:=0 to anzahl_shapes do begin
         //ich habe einen array von shapes oben deklariert myshape:array[0..6] of TShape;
        myshape[0]:= ???
        ... 
end;


wie soll ich das jetzt bewerkstelligen?
danke vielmals,
florian

_________________
Jeder braucht die Zeit, die Zeit zum Lernen, man kommt nicht auf die Welt und sieht die Dinge wie sie sind....(onkelz)
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Mi 02.06.04 13:01 
Hallo,

folgendes sollte Dein Problem lösen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure CreateShapes(aForm:TForm); 
var loop:integer; 
begin 
  for loop:=0 to anzahl_shapes do 
  begin 
    myshape[0]:=TShape.Create(aForm);
    myshape[0].Parent:=aForm;
    ... 
  end; // for loop
end;


Aufrufen kannst Du die Procedure (an beliebiger Stelle in Deinem Hauptformular) wie folgt:

ausblenden Delphi-Quelltext
1:
   CreateShapes(Self);					

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)