I'm trying to display FMX form from a DLL and I'm failing miserably. To be precise, form shows OK, but cleaning after it doesn't work. When I close the form, its taskbar icon stays on the taskbar. Also, I cannot shut down my DLL host application as it gets stuck somewhere (seemingly in d3d11.dll).
I'm trying to display FMX form from a DLL and I'm failing miserably. To be precise, form shows OK, but cleaning after it doesn't work. When I close the form, its taskbar icon stays on the taskbar. Also, I cannot shut down my DLL host application as it gets stuck somewhere (seemingly in d3d11.dll).
Full project is here: https://github.com/gabr42/GpDelphiCode/tree/master/FMX%20from%20DLL
Long StackOverflow question with all details: https://stackoverflow.com/q/47159637/4997
If anybody can help, I'd be most grateful. I did search around, but all posts on that topic seem to be from 2011 and they refer to XE2. FireMonkey was much different back then and those old solutions don't work anymore.
https://stackoverflow.com/q/47159637/4997
Full project is here: https://github.com/gabr42/GpDelphiCode/tree/master/FMX%20from%20DLL
Long StackOverflow question with all details: https://stackoverflow.com/q/47159637/4997
If anybody can help, I'd be most grateful. I did search around, but all posts on that topic seem to be from 2011 and they refer to XE2. FireMonkey was much different back then and those old solutions don't work anymore.
https://stackoverflow.com/q/47159637/4997
Have a look at Dlphi Xe2 Foundations (Chris Rolliston). I has a great article on how to display forms from a dll or package and load them dynamically.
ReplyDeleteYes. And as I said - XE2 doesn't really apply anymore.
ReplyDeleteI apologize, I did not read that.
ReplyDeleteHave a look at this code I played with. This is based on the article in Chris's book. He assisted me in modifying it to work in Berlin. (Sorry for the size, but I was playing with styles as well.)
ReplyDeletedrive.google.com - Lab93_Dynamically_Load_Packages_20170410.zip
Johan Swart your main application is already FMX, while Primož Gabrijelčič project is a VCL application (host) and FMX dll. FMX has a very different message loop etc so I think this collide with each other. I think a colleague had something similar with VCL and FMX in one app...
ReplyDeleteFound back some PoC code, hope this helps:
ReplyDelete- we have a mixed vcl and fmx application
- we have a fmx bridge, which is initialized in the .dpr and finalized:
...
Application.Initialize;
FmxBridge.Initialize;
...
Application.Run;
FmxBridge.Finalize;
- we must have enabled the fastmm "NeverUninstall" define, because FMX keeps some stuff in memory (and we have some small initial memory leaks)
- bridge code:
unit FmxBridge;
interface
procedure Initialize;
procedure Finalize;
implementation
uses
Vcl.Forms, Winapi.Windows, FMX.Platform.Win, FMX.Forms;
procedure Initialize;
begin
Fmx.Forms.Application.Initialize;
end;
procedure Finalize;
begin
Fmx.Forms.Application.Terminate;
Fmx.Forms.Application.HandleMessage;
end;
function VclWnd: HWND;
begin
Result := Vcl.Forms.Application.Handle;
end;
initialization
RegisterApplicationHWNDProc(VclWnd);
end.
Primož Gabrijelčič does André Mussche's code work? This is an interesting problem and we ran into it at InstallAware as well (calling an FMX form inside a DLL from a VCL host EXE).
ReplyDeleteNope, still hangs. Code available in https://github.com/gabr42/GpDelphiCode/tree/andre-bridge/FMX%20from%20DLL if anybody would like to test.
ReplyDeleteWeirdly, the app doesn't hang on exit if I don't unload the FMXDLL. https://github.com/gabr42/GpDelphiCode/tree/no-freelibrary/FMX%20from%20DLL
ReplyDeleteYour DLL will probably have a copy of the FMX TApplication instance running. Can you debug and inspect that, and check its state? It will interact with VCL by accident, re message processing
ReplyDelete