Einzelnen Beitrag anzeigen

Benutzerbild von Uwe Raabe
Uwe Raabe

Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.024 Beiträge
 
Delphi 12 Athens
 
#26

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

  Alt 20. Apr 2018, 16:10
Ich will auch mal:
Delphi-Quellcode:
unit uFormUtils;

interface

uses
  Vcl.Forms;

type
  TFormUtils = record
  public
    class procedure ShowForm<T: TCustomForm>(var Instance: T); static;
  end;

implementation

class procedure TFormUtils.ShowForm<T>(var Instance: T);
begin
  if Instance = nil then begin
    Instance := T.Create(Application);
  end;
  Instance.Show;
end;
Der (typsichere) Aufruf wäre dann in etwa so: TFormUtils.ShowForm<TForm2>(Form2);
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat