![]() |
Re: Variable innerhalb einer anderen
Ich durchschaue zwar nicht ganz dein Progrmm, aber prinzipiell geht das schon. Erstmal heißt es: Records weg, OOP her :wink: . Du hast bei deiner Klasse eine Array-Property, in der die Werte gespeichert sind. Als Index der Property kannst du einen String benutzen, wenn du die Property zusätzlich noch als default markierst, kannst du sie so ansprechen:
Delphi-Quellcode:
Hier mal ein konkretes Beispiel (Ansprechen von Bitmaps über einen Namen):
Konfiguration['Gateway'] := ...;
Delphi-Quellcode:
Anwendung:
type
TBitmapCollection = class private FBitmapList: TObjectList; FNameList: TStringList; function GetBitmap(AName: string): TBitmap32; public constructor Create; destructor Destroy; override; procedure Add(ABit: TBitmap32; AName: string); function AddNew(AName: string): TBitmap32; property Bitmap[AName: string]: TBitmap32 read GetBitmap; default; end; implementation { TBitmapCollection } function TBitmapCollection.GetBitmap(AName: string): TBitmap32; begin Result := TBitmap32(FBitmapList.Items[FNameList.IndexOf(AName)]); end; procedure TBitmapCollection.Add(ABit: TBitmap32; AName: string); begin FBitmapList.Add(ABit); FNameList.Add(AName); end; function TBitmapCollection.AddNew(AName: string): TBitmap32; begin Result := TBitmap32.Create; Add(Result, AName); end; destructor TBitmapCollection.Destroy; begin FBitmapList.Free; FNameList.Free; inherited; end; constructor TBitmapCollection.Create; begin inherited; FBitmapList := TObjectList.Create; FNameList := TStringList.Create; LoadGraphicRessources; end; end.
Delphi-Quellcode:
(Stammt aus
try
Stream := TFileStream.Create('Graphics.prr', fmOpenRead); LoadPNGintoBitmap32(Collection.AddNew('blubb'), Stream, Alpha); Collection['blubb'].Line(...); finally Stream.Free; end; ![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:37 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