[Lazarus] Form in DLL
Michael Fuchs
freepascal at ypa-software.de
Mon Apr 30 23:43:52 CEST 2012
Hello,
in http://bugs.freepascal.org/view.php?id=1866 is described, that forms
in dlls are not working at this moment. I have coded a dll which opens a
form and it works. But I am not sure if there are some hidden problems
or side-effects. Before I implement this in a real application, I want
to read some opinions.
Here is the code for the DLL:
---->8---->8---->8---->8---->8---->8---->8---->8----
library server;
{$mode objfpc}
{$H+}
{$DEFINE USE_BIN_STR}
uses
Classes, SysUtils, Interfaces, Windows, LCLType, Unit1, Forms;
{$R *.res}
procedure ShowText(AText: String); stdcall;
begin
try
Form1 := TForm1.Create(Application);
Form1.Memo1.Text := AText;
Form1.ShowModal;
finally
FreeAndNil(Form1);
end;
end;
exports
ShowText;
begin
Application.Initialize;
end.
---->8---->8---->8---->8---->8---->8---->8---->8----
The Unit1 contains a form with a TMemo on it. I can show the form and
load some text into it via:
---->8---->8---->8---->8---->8---->8---->8---->8----
procedure DllShowText(AText: String); stdcall; external 'server.dll'
name 'ShowText';
// ...
DllShowText('Blafasel');
---->8---->8---->8---->8---->8---->8---->8---->8----
Is this a bad idea?
Thanks for any help.
Michael
More information about the Lazarus
mailing list