Vielen Dank.
Ich hab das mal so gemacht:
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:
| type TDownloadURL = record Titel: string; URL: string; end;
type pExItemData = ^TExtItemData; TExtItemData = record Titel: string; URL: string; end;
var Form1: TForm1; Download: TDownloadURL; pData: pExItemData;
implementation
{$R *.dfm}
procedure TForm1.Button3Click(Sender: TObject); begin New(pData); With pData^ do begin Titel := Download.Titel; URL := Download.URL; end; ComboBox1.Items.AddObject(Download.Titel,TObject(pData)); Dispose(pData); end; |
Das funktioniert soweit, neue Einträge hinzuzufügen, aber wenn ich es wieder auslesen möchte:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
| procedure TForm1.ComboBox1Change(Sender: TObject); begin if ComboBox1.ItemIndex > -1 then begin if ComboBox1.Items.Objects[ComboBox1.ItemIndex] <> Nil then begin pData := pExItemData(ComboBox1.Items.Objects[ComboBox1.ItemIndex]); With pData^ do begin Label1.Caption := URL; end; end; end; end; |
dann erhalte ich folgende fehlermeldung:
Delphi-Quelltext
1:
| Zugriffsverletzung bei Adresse 40006CFE in Modul 'rtl70.bpl'. Lesen von Adresse 00000008. |
Habe ich vieleicht etwas vergessen?
Edit: Ich habe den fehler gefunden, das Problem lag daran, das ich nach Button1 Klick, pData wieder freigegeben habe und deshalb bekam ich dann die Zugriffsverletzung.
Edit: Noch ein Problem habe ich, wenn ich mehrere Links hinzufüge, dann haben alle Einträge das zuletzt hinzugefügte URL, woran könnte das liegen?
MfG