Earlier (a year ago) I stated this: "To create second GUI thread in a DLL, I must do things exactly as in standard application"
.
This is exactly
what everybody who is searching for this solution should do.
Let me explain, step by step:
we must add our application object to our thread:
type TMyThread = class(TThread) private ThreadApplication: TApplication;
now some modification to definition of
procedure TMyThread.Execute;
procedure TMyThread.Execute; begin if not Terminated then begin try ThreadApplication:=TApplication.Create(nil); try ThreadApplication.Initialize; ThreadApplication.CreateForm(TMyForm, Form); ThreadApplication.Run; finally ThreadApplication.Free; end; finally Terminate; end; end; end;
so, this is it, now we have message pump in a second GUI thread in a DLL.
Recently I found confirmation to this solution in a Delphi-Jedi blog, wrote by Christian Wimmer:
http://blog.delphi-jedi.net/2008/05/27/winlogon-notification-package/
Thank You very much.