I’d like to detect when a new form has been created.
Now I use the Screen.ActiveFormChange event and check for new forms in Screen.CustomForms but ActiveFormChange is fired after the OnShow event of the form.
I’d like to detect the form even before OnShow was fired. Is there any way to do this without modifying the Vcl.Forms unit?
I’d like to detect all forms (also Delphi modal messages etc.) therefore inheriting all forms from a custom class is not possible (correct me if I am wrong).
Alternatively, is it possible to detect that a new component was added to some TComponent.FComponents list?
You can use the
SetWindowsHookExfunction to install aWH_CBTHook, then you must implement a CBTProc callback function and finally intercept one of the possible code values for this hook. in this case you can try withHCBT_ACTIVATEorHCBT_CREATEWND.Check this sample for the
HCBT_ACTIVATECode.