![]() |
Suche nach einem Formtyp in einer ObjectListe von Forms
unsere App erzeugt diverse Forms zur Laufzeit, jedes Form wird in einer Liste abgelegt um später wieder darauf zugreifen zu können
funktionalercode geht wie z.B. folgt:
Delphi-Quellcode:
ich benötige nun eine Funktion welche mir true/false zurück gibt je nachdem of ein AFormList: TObjectList; for i := 0 to AFormList.Count - 1 do begin /// /// check if correct Form type /// if (AFormList.Items[i] is TProjectIForm) then begin ... MySelectedForm := (AFormList.Items[i] as TProjectIForm); .... end; bestimmter Formtype in der Liste vorhanden ist
Delphi-Quellcode:
function TPForm.FormtypeExisits(anyForm: TObject): boolean;
var i: Integer; begin Result := False; for i := 0 to AFormList.Count - 1 do begin if (AFormList.Items[i] is anyForm) then Result := True; end; end; Problem wie Übergebe ich einen Typen als Parameter an die Funktion FormtypeExisits ? |
AW: Suche nach einem Formtyp in einer ObjectListe von Forms
Delphi-Quellcode:
vielleicht so?
type
TFormClass = class of TForm; function TForm1.formExists(form: TFormClass): Boolean; begin for var i := 0 to fFormList.Count - 1 do begin result := false; if (AFormList[i] is form) then begin result := true; break; end; end; end; Grüße Klaus |
AW: Suche nach einem Formtyp in einer ObjectListe von Forms
Hallo,
da deine Forms ja idR von TForm abgeleitet sind, wäre ClassName eine Möglichkeit der Unterscheidung. |
AW: Suche nach einem Formtyp in einer ObjectListe von Forms
Funktioniert sowas:
Delphi-Quellcode:
function TPForm.FormtypeExisits(anyForm: TObject): boolean;
var i: Integer; begin Result := False; for i := 0 to AFormList.Count - 1 do begin if (AFormList.Items[i].ClassType = anyForm.ClassType) then Result := True; end; end; |
AW: Suche nach einem Formtyp in einer ObjectListe von Forms
Danke, funktioniert
|
AW: Suche nach einem Formtyp in einer ObjectListe von Forms
Spontan würde ich auch versuchen, eine
![]() |
AW: Suche nach einem Formtyp in einer ObjectListe von Forms
Spontan hätte ich hier ein
Delphi-Quellcode:
vorgeschlagen.
TDictionary/TObjectDictionary<TFormClass, TForm>
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:05 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 by Thomas Breitkreuz