Einzelnen Beitrag anzeigen

Furtbichler
(Gast)

n/a Beiträge
 
#21

AW: Viele Formulare in einem Projekt

  Alt 9. Nov 2013, 19:17
Delphi ist ein RAD-Tool (eigentlich: DAS RAD-Tool). RAD bedeutet in erster Linie 'Rapid'. Und da ist es logisch, das in diesem Kontext die Formulare sofort zur Verfügung stehen. Das könnte man auch mit Lazy-Load umsetzen, aber historisch hat Borcardero das nun mal anders gelöst. Schade eigentlich, aber egal.

Schön wäre so ein Pattern beim Erzeugen eines neuen Formulars: Statt
Delphi-Quellcode:
Unit MyForm;
interface
uses...
Type
  TMyForm...

Var
  MyForm : TMyForm;
...
// in der DPR
Application.CreateForm(MyForm, TMyForm);
einfach so (Lazy Load):

Delphi-Quellcode:
Unit MyForm;
interface
uses...
Type
  TMyForm...

Function MyForm : TMyForm;
implementation
Var
  _myForm : TMyForm:

Function MyForm : TMyForm;
begin
  if _myForm=Nil then Application.CreateForm(_myForm, TMForm);
  result := _myForm
End;
  Mit Zitat antworten Zitat