<div>Thans Michael.</div><div> </div><div><span class="hps"> I have not</span> <span class="hps">developed</span> <span class="hps">with threads.</span> <span class="hps">I've tried</span> <span class="hps">the following.</span> <span class="hps">I do not know</span> <span class="hps">if it is right</span><span>.</span> <span class="hps">The window</span> <span class="hps">is created from the</span> <span class="hps">main application,</span> <span class="hps">but you can not</span> <span class="hps">close it.</span></div>
<div><span class="hps"></span> </div><div><span class="hps">This code goes in DLL:</span></div><div><span class="hps"></span> </div><div><span class="hps">...</span></div><div><span class="hps"></span> </div><div><span class="hps">Type<br>
TGUI2Thread = class(TThread)<br> private<br> protected<br> procedure Execute; override;<br> public<br> Constructor Create(CreateSuspended : boolean);<br> end; </span></div><div><span class="hps"></span> </div>
<div><span class="hps">...</span></div><div><span class="hps"></span> </div><div><span class="hps">constructor TGUI2Thread.Create(CreateSuspended : boolean);<br> begin<br> FreeOnTerminate := True;<br> inherited Create(CreateSuspended);<br>
end; </span></div><div><span class="hps"></span> </div><div><span class="hps">...</span></div><div><span class="hps"></span> </div><div><span class="hps"> procedure TGUI2Thread.Execute;<br> begin<br> Application.Initialize;<br>
Application.CreateForm(TForm2, Form2);<br> Application.Run;<br> end; </span></div><div><span class="hps"></span> </div><div><span class="hps">...</span></div><div><span class="hps"></span> </div><div><span class="hps">// Function exported and called from main window</span></div>
<div><span class="hps">procedure DllMessage(); export;<br>var<br> GUI2Thread: TGUI2Thread;<br>begin </span></div><div><span class="hps"> GUI2Thread := TGUI2Thread.Create(True);<br> GUI2Thread.Execute;<br>end;</span></div>
<div> </div><div> </div><div>Thanks a lot for your help.</div><div>Juan.</div><div> </div><div><br> </div><div class="gmail_quote">2011/8/9 Michael Schnell <span dir="ltr"><<a href="mailto:mschnell@lumino.de">mschnell@lumino.de</a>></span><br>
<blockquote style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" class="gmail_quote"><div class="im">On 08/08/2011 06:54 PM, Juan Sánchez wrote:<br>
<blockquote style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" class="gmail_quote">
I have tried it. From main program, one button call a procedure in a DLL with a form. Inside this procedure I code this:<br>
Application.Initialize;<br>
Application.CreateForm(TForm2, Form2);<br>
Form2.ShowModal();<br>
Is this Ok?<br>
</blockquote>
<br></div>
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.<br>
<br>
It might be possible to do<br>
<br>
GUI2Thread.Execute;<br>
begin<div class="im"><br>
Application.Initialize;<br>
Application.CreateForm(TForm2, Form2);<br></div>
Application.Run;<br>
...<br>
<br>
in a thread.<br>
<br>
(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.)<br>
<br>
Good luck (I never tested this) :) !<br><font color="#888888">
<br>
-Michael</font><div><div></div><div class="h5"><br>
<br>
--<br>
______________________________<u></u>_________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org" target="_blank">Lazarus@lists.lazarus.<u></u>freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.<u></u>freepascal.org/mailman/<u></u>listinfo/lazarus</a><br>
</div></div></blockquote></div><br>