Главная страница | назад





Article #17004: Differences between Create(Self) and Create(Application)

 Question and Answer Database
FAQ2004D.txt Differences between Create(Self) and Create(Application)
Category :VCL
Platform :All
Product :All 32 bit
Question:
What's the difference between TForm.Create(Self) and
TForm.Create(Application)?
Answer:
Self is an implicit variable which can only be used within class
methods, and refers to the current class instance. So "Self" within a
method of the TForm1 class refers to the current instance of TForm1.
When you create a form or component, you pass its owner in the
constructor. When a form or component is freed, it automatically frees
all the components which it owns as well.
So if you pass an Application as the owner when you create a form
instance, the form instance will be automatically freed when the
Application is freed.
If you pass a form instance as the owner when you create another form
instance, the second form will be freed when the first is freed.
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99