Does Delphi provide some kind of event or hook for form creation (or more generally, form lifecycle events)?
So that if somewhere in the code a form is created and shown (modal or non-modal, dynamically or in the usual app starup stage), Delphi calls an event handler which allows to log / analyse / modify the form before it is shown?
I know there are options which involve introducing a base form class or a custom form creation procedure, but for existing applications which already have many forms it would be 'nice to have' a non-intrusive option to add something similar to cross-cutting concerns in Aspect oriented programming (AOP).
For example, if I had some code for usage statistics tracking which injects additional event handlers, I could simply add this functionality for every form, developers would not have to change the application code, only add code similar to this
...
Application.OnNewForm := MyNewFormCreated;
...
procedure TMyApp.MyNewFormCreated(Sender: TCustomForm);
begin
// iterate over components and do other stuff with the new form
...
end;
The closest option I can think of at the moment that could fit your need is the Screen.OnActiveFormChange
event that is triggered every time the current active form changes. But that might be too late in the process for your needs.