Look at the source code, and you yourself can answer this question!
TForm inherits far from TComponent, if we look at the TComponent destructor, we will see this (at least in DelphiXE7):
destructor TComponent.Destroy; begin Destroying; RemoveFreeNotifications; DestroyComponents; if FOwner <> nil then FOwner.RemoveComponent(Self); FObservers.Free; inherited Destroy; end;
There are two important lines here:
This will destroy all its components upon destruction prior to the destruction of the owner himself.
if FOwner <> nil then FOwner.RemoveComponent(Self);
Notifies the owner that the object belonging to him no longer exists and that he should be removed from the list of components of the owner.
therefore, in your case, Application.MainForm will belong to your TMyForm instance, but when it is destroyed, it will disappear from the list of components of the main form.
In short, your code is great and will not break. But to make it clear that you are managing the component life cycle, you must pass nil as the owner in the constructor. And, as Sertac Akyuz already mentioned in the comments, you will avoid calling FOwner.RemoveComponent(Self); which will save some processor cycles ...
source share