[Original] difference Delphi Create (Application) and Create (nil) of

Delphi Create (Application) and Create (nil) the difference between:

E.g:

Form1:=TForm1.Create(Application);

Form1:=TForm1.Create(nil);

 

Create (Application): the program will be created when objects are added to the component (TComponent) owner of the object list, the object was undoubtedly the main view and the destruction of the slave owner of the object when the object is first destroyed, that is, when the Application object is automatically released when the release subordinate objects.

    Here again a derivative concept and application object i.e. the Application object is an instance of class TApplication, Delphi applications are encapsulated in the Application object, Application object for unified management application framework.

    Application object is created during initialization implied a record library window size to zero, this is the main window of the program, all other child windows are the main window.

Create (nil): When the owner of the object parameter to nil, components need to be destroyed by hand, otherwise it will cause a memory leak.

 

From: https: //www.cnblogs.com/guorongtao/p/12032958.html

Guess you like

Origin www.cnblogs.com/guorongtao/p/12032958.html