Does Delphi provide any kind of event or hook to create the form (or, moreover, form lifecycle events)?
So, if somewhere in the code a form is created and displayed (modal or non-modal, dynamically or at the usual stage of application launch), does Delphi call an event handler that allows you to register / analyze / change the form before it is displayed?
I know that there are options that include introducing the base class of the form or the procedure for creating a custom form, but for existing applications that already have many forms, it would be nice to have a non-intrusive option to add something like cross-cutting problems in Aspect -oriented programming (AOP).
For example, if I had some code for tracking usage statistics that introduces additional event handlers, I would just add this functionality for each form, developers would not have to change the application code, add only 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;
source share