View Issue Details

IDProjectCategoryView StatusLast Update
0001866LazarusLCLpublic2016-05-11 07:58
ReporterPaul HAssigned ToOndrej Pokorny 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
PlatformWin32OSXPOS VersionSP2
Product Version0.9.12Product Build 
Target VersionFixed in Version 
Summary0001866: LCL not fully supported in library applications (.dlls) - Plug-in applications with GUI not working.
DescriptionMaking a .dll that has a user interface (under Win32) is not working. Application is not initialized and widgets don't respond.

This makes creating plug-ins (with UI) of any kind close to impossible.
Tagsdll, library
Fixed in Revision
LazTarget-
WidgetsetWin32/Win64
Attached Files

Relationships

duplicate of 0007182 resolvedOndrej Pokorny Problems using LCL in DLL 
duplicate of 0007181 resolvedBart Broersma Problems using LCL in DLL 
related to 0026439 resolvedJuha Manninen GlobalIdentToInt causes shared library to enter zombie state 

Activities

Felipe Monteiro de Carvalho

2007-11-27 13:39

developer   ~0016416

Please send a compilable example.

Markus Müller

2012-04-30 19:06

reporter   ~0059131

Hello,

I can need it. When it is implemented, then I want test.

Anton Kavalenka

2012-04-30 19:14

reporter   ~0059132

@Markus
There are partial solutions in 0007182 and 0007181

Markus Müller

2012-05-01 07:29

reporter   ~0059155

Yes, http://bugs.freepascal.org/view.php?id=7182 works!
Nice.

Ondrej Pokorny

2016-05-10 23:58

reporter   ~0092508

It is possible in Lazarus 1.7. See http://wiki.freepascal.org/Form_in_DLL

Everybody is welcome to donate bounties (if still interested) to Lazarus ;)

Balázs Székely

2016-05-11 07:13

developer   ~0092515

@Ondrej
Nice example! In addition, I would load the library dynamically. This method it's
particularly useful for implementing plugins or modules, because they permit waiting to load the plugin/module until it's needed.

1. Add dynlibs to uses clauses. Instead of:
const
{$IFDEF WINDOWS}
  DLLDialogLib = 'DLLDialog.dll';
{$ELSE}
  DLLDialogLib = 'DLLDialog.so';
{$ENDIF}

you can write:
const
  DLLDialogLib = 'DLLDialog.' + SharedSuffix;

2. Load the dll dynamically(based on the wiki example "program MainApp"):
...
type
  TDLLDialog_Init = procedure(DisableFormsCallBack, EnableFormsCallback: TEnableDisableFormsCallBack);
var
  LibHandle: TLibHandle = NilHandle;
  LibName: String;
  FarProc: TFarProc;
  DLLDialog_Init: TDLLDialog_Init;
begin
  Application.Initialize;
  Application.CreateForm(TMainForm, MainForm);

  LibName := ExtractFilePath(ParamStr(0)) + DLLDialogLib;
  LibHandle := LoadLibrary(LibName);
  if LibHandle <> NilHandle then
  begin
    FarProc := GetProcedureAddress(LibHandle, 'DLLDialog_Init');
    if FarProc <> nil then
    begin
      DLLDialog_Init := TDLLDialog_Init(FarProc);
      DLLDialog_Init(@DisableFormsCallBack, @EnableFormsCallback);
    end;
  end;

  try
    Application.Run;
  finally
    DLLDialog_Final;
  end;
end.

Ondrej Pokorny

2016-05-11 07:38

reporter   ~0092516

1. Good, didn't know that.
2. The example is about how to get the LCL working from a library and not how to load a library dynamically. But you are welcome to adapt the wiki example if you want to :)

Balázs Székely

2016-05-11 07:58

developer   ~0092518

>>get the LCL working from a library and not how to load a library dynamically
I'm aware of that, but the LCL has worked inside a library since a long time ago(at least in the way I needed) plus usually you need lcl in lib. mostly for plugins/modules.
http://forum.lazarus.freepascal.org/index.php/topic,30252.msg192411.html#msg192411


>>But you are welcome to adapt the wiki example if you want to :)
This is a good idea! I will adapt it later!

Issue History

Date Modified Username Field Change
2006-03-14 12:21 Paul H New Issue
2006-03-14 12:21 Paul H Widgetset => Win32
2006-03-14 13:56 Vincent Snijders Target => post 1.0
2006-03-14 13:56 Vincent Snijders Status new => acknowledged
2007-11-27 13:39 Felipe Monteiro de Carvalho Note Added: 0016416
2007-11-27 15:08 Felipe Monteiro de Carvalho Relationship added duplicate of 0007182
2007-11-27 15:08 Felipe Monteiro de Carvalho Relationship added duplicate of 0007181
2012-02-04 12:02 Zeljan Rikalo LazTarget post 1.0 => 1.2
2012-04-30 19:06 Markus Müller Note Added: 0059131
2012-04-30 19:14 Anton Kavalenka Note Added: 0059132
2012-05-01 07:29 Markus Müller Note Added: 0059155
2014-01-14 15:16 Martin Friebe LazTarget 1.2 => 1.4
2014-07-01 20:16 Juha Manninen Relationship added related to 0026439
2014-10-01 10:22 Reinier Olislagers Tag Attached: dll
2014-10-01 10:22 Reinier Olislagers Tag Attached: library
2015-04-27 21:59 Juha Manninen LazTarget 1.4 => -
2016-05-10 23:58 Ondrej Pokorny Note Added: 0092508
2016-05-10 23:58 Ondrej Pokorny Status acknowledged => resolved
2016-05-10 23:58 Ondrej Pokorny Resolution open => fixed
2016-05-10 23:58 Ondrej Pokorny Assigned To => Ondrej Pokorny
2016-05-11 07:13 Balázs Székely Note Added: 0092515
2016-05-11 07:38 Ondrej Pokorny Note Added: 0092516
2016-05-11 07:58 Balázs Székely Note Added: 0092518