Einzelnen Beitrag anzeigen

TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.060 Beiträge
 
Delphi 10.4 Sydney
 
#8

AW: Form-Event global für alle Formulare überschreiben?

  Alt 20. Apr 2018, 10:18
Das versteh ich nicht so ganz.

Das hier steht in meiner DPR:
Delphi-Quellcode:
Application.CreateForm(TFormListe, FormListe);
Application.CreateForm(TAlphabet, FormAlphabet);
Die würde ich gerne da rausnehmen und selber erzeugen. Kein Problem. Aber das ergibt dann viel von dem o.g. doppelten Code.
Wie wärs mit:
Delphi-Quellcode:
function CreateAndShowForm(const AFormClass: TFormClass; AFormInstance: TCustomForm): Boolean;
begin
 if not Assigned(AFormInstance) then
  AFormInstance := AFormClass.Create(Application);

 AFormInstance.Show;

 Result := AFormInstance.Visible;
end;
Delphi-Quellcode:
CreateAndShowForm(TFormListe, FormListe);
CreateAndShowForm(TAlphabet, FormAlphabet);
  Mit Zitat antworten Zitat