While taking an existing monolithic C++Builder VCL application and splitting it into an exe + DLLs, I'm running into problems with TApplication.
The DLL projects and the exe project have the following options enabled, so they should all share the memory manager and VCL libraries:
- Link with Dynamic RTL
- Link with the Delphi Runtime Library
- Link with runtime packages
From what I understand, these options are needed for issues like memory allocations and VCL component operations to work across DLL boundaries.
Things are mostly working. However, the global TApplication instance is apparently initialized from within one of the DLLs, not from within the exe, with several unwanted results:
- System::IsLibrary is incorrectly set to true.
- Application->Icon is not set.
- Application->Handle is not set.
- Because Application->Handle is not set, various other problems arise: shortcut keys don't work, there are problems with thread synchronization, etc.
I can work around these problems by setting Application->Icon->Handle and calling Application->CreateHandle from WinMain, but I'm not sure that this is the right solution (especially since the docs say "do not call CreateHandle").
What's the right way to split a C++Builder VCL app into DLLs while sharing VCL components?