[Lazarus] RE : Forms in DLL

Michael Schnell mschnell at lumino.de
Tue Aug 9 12:17:13 CEST 2011


On 08/08/2011 06:54 PM, Juan Sánchez wrote:
> I have tried it. From main program, one button call a procedure in a 
> DLL with a form. Inside this procedure I code this:
> Application.Initialize;
> Application.CreateForm(TForm2, Form2);
> Form2.ShowModal();
> Is this Ok?

I don't think so. The main thread of the main application (may same be 
in Pascal or some other language) already attaches to the external GUI 
and I don't suppose it's allowed or makes sense to have the same thread 
create another GUI hook.

It might be possible to do

GUI2Thread.Execute;
  begin
   Application.Initialize;
   Application.CreateForm(TForm2, Form2);
   Application.Run;
  ...

in a thread.

(In the main program itself this is not allowed, as the LCL GUI 
environment is not reentrant, but I understand that the DLL uses it's 
own LCL GUI environment.)

Good luck (I never tested this) :) !

-Michael




More information about the Lazarus mailing list