Where and when is the Application instance created?
(Same goes for the Screen instance) .
I don’t see anything in the Forms or System initialization section.
In the CPU windows before Application.Initialize, I see a call to @_InitExe (SysInit) – which leads to _StartExe (System) and a whole lot of asm code – Which does not create the Application instance as far as I can tell.
What am I missing here?
It’s easy enough to work this out from the code. You just do a text search for
TApplication.Create. For example using the IDE’s Find in Files feature.But you can always be lazy and get the debugger to do it.
TApplication.Create.When the program breaks, look at the call stack. You will see that the
TApplicationobject is instantiated fromInitControlsin theControlsunit. AndInitControlsis called from theinitializationsection of theControlsunit.The full call stack for a plain vanilla VCL app looks like this:
Doing the same thing with
TScreen.Create, you will see that theTScreenobject is also instantiated inInitControls().I won’t try and explain all of this. I think there’s enough information and advice here for you to work it all out from here. Although this is the call stack from an XE3 application, it will look just the same for your Delphi 5 application.