![]() |
Re: Handling von Objekten (vom Typ TObject)
Hey, ich bin es doch noch mal. Mir sind beim Debuggen nun doch noch eine Menge Sachen aufgefallen. Und folgendes hatte ich beim ersten Mal überlesen:
Zitat:
![]()
Delphi-Quellcode:
Das Eintragen klappt hier, dennoch sind mir folgende Dinge aufgefallen:
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Contnrs; type TMarke = (maOpel, maVW, maAudi, maMercedes); type TAuto = class(TObject) Marke : TMarke; Modell : String; Baujahr : Integer; end; type TAutoSammlung = class(TObjectlist) protected function getCar(Index: Cardinal) : TAuto; virtual; procedure setCar(Index: Cardinal; Auto : TAuto); virtual; public function AddAuto(Auto: TAuto): Cardinal; virtual; function RemoveAuto(Auto: TAuto): Cardinal; virtual; function GetAuto(Auto: TAuto): Cardinal; virtual; procedure InsertAuto(Index: Cardinal; Auto: TAuto); virtual; property Items[index: Cardinal]: TAuto read getCar write setCar; end; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private { Private-Deklarationen } public autoSammlung : TAutoSammlung; end; var Form1: TForm1; implementation {$R *.dfm} function TAutoSammlung.getCar(Index: Cardinal): TAuto; begin Result := TAuto(inherited Items[Index]); end; procedure TAutoSammlung.setCar(Index: Cardinal; Auto: TAuto); begin inherited Items[Index] := Auto; end; function TAutoSammlung.AddAuto(Auto: TAuto): Cardinal; begin Result := inherited Add(Auto); end; function TAutoSammlung.RemoveAuto(Auto: TAuto): Cardinal; begin Result := inherited Remove(Auto); end; function TAutoSammlung.GetAuto(Auto: TAuto): Cardinal; begin Result := inherited IndexOf(Auto); end; procedure TAutoSammlung.InsertAuto(Index: Cardinal; Auto: TAuto); begin inherited Insert(Index, Auto); end; procedure TForm1.FormCreate(Sender: TObject); var newCar : TAuto; begin autoSammlung := TAutoSammlung.Create; newCar := TAuto.Create; newCar.Marke := maOpel; newCar.Modell := 'Astra'; newCar.Baujahr := 1995; autoSammlung.AddAuto(newCar); newCar.Marke := maAudi; newCar.Modell := 'TT'; newCar.Baujahr := 2001; autoSammlung.AddAuto(newCar); end; end. 1.) Wenn ich im Debug-Modus über autoSammlung gehe, bekomme ich keine Einträge angezeigt, sondern ein (). 2.) Links im Fenster "Lokale Variablen" (ist ja ein Debugfenster) steht z.B. bei Sender: E2117 Auf Variable Sender kann wegen Optimierung nicht zugegriffen werden. Ich habe das in meinem richtigen Projekt auch bei den Properties wie z.B. "Marke". Woher kommt das? 3.) Oder ist das vielleicht normal, dass der Debugger diese Informationen nicht so anzeigen kann, wie ich mir das vielleicht denke (also, dass ich die in autoSammlung gepackten Objekte zur Laufzeit sehen kann)? |
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:58 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz