Autor Beitrag
McFarlane
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68

WIN XP Prof.
Delphi 2005 PE, Turbo Delphi 2006, PHP (Eclipse)
BeitragVerfasst: Fr 06.07.07 18:10 
Moin,
ich kann mich grad leider nicht mehr dran erinnern, wie man eine Adresse einer Objektinstanz in eine Liste speichert... :oops:
hatte das schon mal gemacht, aber das Programm hab ich grad nicht hier.

Das hier ist der kritische QT;
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure Tffeld.initalize(x,y: integer);
var i,j:integer;
begin
  FOR j:=0 TO x-1 DO
  begin
    FOR i:=0 TO y-1 DO
    begin
      Stein := TStein.create(i*20,j*20,ffeld);
      SteinList.Add(@Stein);
    end;
  end;
end;


bei SteinList.Add(@Stein) kackt er mir ab... (AcessViolation)

wie ging denn das?

Hier ist mal meine Stein Klasse:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
type TStein = class
  private
    bild     : Timage;
    art      : (frei,start,ende,wand);
    popmenu  : TPopupMenu;
    menitem  : array [1..4] of TMenuItem;
  public
    constructor create(x,y: integer; master: TWinControl);
    procedure set_art(a: string);
    procedure menu_popup(Sender: TObject);
    procedure menu_click_start(Sender: TObject);
    procedure menu_click_ende(Sender: TObject);
    procedure menu_click_frei(Sender: TObject);
    procedure menu_click_wand(Sender: TObject);
end;


Thx, McFarlane

_________________
21 ist nur die halbe Wahrheit...
Robinator
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 275

WinXP
BDS 2006
BeitragVerfasst: Fr 06.07.07 18:32 
Was ist denn SteinList?

Generell is das Add(@Stein) Falsch, Stein ist ja eh schon nen Pointer, du kannst also einfach SteinList.Add(TStein.Create(bla) machen ;)

gruss

_________________
erare humanum est
McFarlane Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68

WIN XP Prof.
Delphi 2005 PE, Turbo Delphi 2006, PHP (Eclipse)
BeitragVerfasst: Fr 06.07.07 18:39 
Aso...
SteinList: TList;

SteinList.add(TStein.create(bla)); geht leider nicht.
Immer noch der gleiche Fehler.

_________________
21 ist nur die halbe Wahrheit...
Robinator
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 275

WinXP
BDS 2006
BeitragVerfasst: Fr 06.07.07 19:08 
Dann is der Fehler im TStein.Create, nicht beim add.

_________________
erare humanum est
McFarlane Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68

WIN XP Prof.
Delphi 2005 PE, Turbo Delphi 2006, PHP (Eclipse)
BeitragVerfasst: Fr 06.07.07 19:45 
wenn ich das mit der Liste auskommentiere, createt er aber schön alles was ich haben will.

_________________
21 ist nur die halbe Wahrheit...
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: Fr 06.07.07 19:48 
Hast du denn irgendwo die Steinliste erstellt? Also Steinlist := TList.Create;?

_________________
We are, we were and will not be.
McFarlane Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68

WIN XP Prof.
Delphi 2005 PE, Turbo Delphi 2006, PHP (Eclipse)
BeitragVerfasst: Fr 06.07.07 19:53 
O M G

Klappt jetzt :)

Kein Kommentar bitte :wink:

Danke.

_________________
21 ist nur die halbe Wahrheit...