View Issue Details

IDProjectCategoryView StatusLast Update
0015126LazarusLCLpublic2016-05-10 23:57
ReporterChristian BuddeAssigned ToOndrej Pokorny 
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product Version0.9.29 (SVN)Product Build 
Target VersionFixed in Version 
Summary0015126: Reparenting forms within a library
DescriptionIt is still not possible to reparent a form from a library (for example a DLL) to a host application. This renders it near to impossible to build a plugin with Lazarus.

Additional InformationI also made a bounty out of this issue and I am willing to pay 100€. Also this is linked to issue 7182 and the person solving this bug can probably expect another 100€ for the other bounty related to that issue.

I am sure this one is tough, but it will be useful I believe.
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetWin32/Win64
Attached Files

Relationships

related to 0007182 resolvedOndrej Pokorny Problems using LCL in DLL 
related to 0018624 resolvedOndrej Pokorny TPopupMenu - Doesn't show on form from DLL 
related to 0022881 resolvedVincent Snijders Combobox loses inheritance information 

Activities

Dmitry Streblechenko

2010-02-02 17:47

reporter   ~0034161

I would not agree that this is a minor issue: the bug makes it impossible to display a form (any form) in a dll, which means that shell extensions or Office add-ins written in FPC cannot display any UI.
Delphi does not have this problem - overriding form's CreateParams methods to provide the right parent handle is all it takes.
This ia a deal breaker for me.

Vincent Snijders

2010-02-02 20:35

manager   ~0034165

Last edited: 2010-02-02 20:36

Dmitry, who are you disagreeing with that is is not a minor issue?

Dmitry Streblechenko

2010-02-03 06:38

reporter   ~0034179

My disagreement was in response to changing the severity to "minor => feature":

2009-11-17 19:10 Vincent Snijders Severity minor => feature

Sorry about not being clear.

user268

2010-02-03 06:43

  ~0034180

Last edited: 2010-02-03 07:15

Vincent: I remember I posted report on FPC long time ago about bug in procedural types with overloading, problem was marked non-existed and closed. Several posts later it was noticed as existed and solved. For me, solving that bug was major, since I often used that technique...

This is maybe a new "feature" Lazarus cannot handle yet, but it generally is a bug from point of a Delphi developer (Lazarus is a Delphi "clone" RAD?). I see no point of such a message "tone"...

Dmitry: Try to avoid argue with managers and be patient, problem will probably be solved in the future (the problem is not simple).

Vincent Snijders

2010-02-03 10:27

manager   ~0034186

Dmitry: the lack of a feature can be a major issue, but it is still a feature.

Nicola Zambon

2010-04-06 23:04

reporter   ~0036503

Last edited: 2010-04-08 08:36

There is a serious bug in LCL: CreateWindowEx functions use a bad hInstance value. This is the reason two instances of TApplication cannot exist into the same process.
I can use forms in dll with this workaround:

var
  MainForm: TForm;
  AppHandle: HWND;

procedure InitDll;
begin
  // LCL bug: LCLType.hInstance (used in CreateWindowEx) differs from System.HINSTANCE (used in RegisterClass)
  LCLType.hInstance := System.HINSTANCE;

  Application.Initialize;
  // I create a dummy main form
  Application.CreateForm(TForm, MainForm);

  // Get Application handle...
  AppHandle := GetWindowLong(MainForm.Handle, GWL_HWNDPARENT);
  if IsLibrary then
  begin
    // ...and hide the taskbar button
    ShowWindow(AppHandle, SW_HIDE);
    SetWindowLong(AppHandle, GWL_EXSTYLE, GetWindowLong(AppHandle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW);
    ShowWindow(AppHandle, SW_SHOW) ;
  end;
end;

initialization
  InitDll

For reparenting form I use SetWindowLong(...,GWL_HWNDPARENT,...) instead of (Delphi) CreateParams override.

Ondrej Pokorny

2016-05-10 23:57

reporter   ~0092507

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 ;)

Issue History

Date Modified Username Field Change
2009-11-17 18:58 Christian Budde New Issue
2009-11-17 18:58 Christian Budde Widgetset => Win32/Win64
2009-11-17 19:09 Vincent Snijders Relationship added related to 0007182
2009-11-17 19:10 Vincent Snijders LazTarget => post 1.2
2009-11-17 19:10 Vincent Snijders Status new => acknowledged
2009-11-17 19:10 Vincent Snijders Severity minor => feature
2010-02-02 17:47 Dmitry Streblechenko Note Added: 0034161
2010-02-02 20:35 Vincent Snijders Note Added: 0034165
2010-02-02 20:36 Vincent Snijders Note Edited: 0034165
2010-02-02 20:36 Vincent Snijders Note Edited: 0034165
2010-02-03 06:38 Dmitry Streblechenko Note Added: 0034179
2010-02-03 06:43 user268 Note Added: 0034180
2010-02-03 07:06 user268 Note Edited: 0034180
2010-02-03 07:08 user268 Note Edited: 0034180
2010-02-03 07:15 user268 Note Edited: 0034180
2010-02-03 10:27 Vincent Snijders Note Added: 0034186
2010-04-06 23:04 Nicola Zambon Note Added: 0036503
2010-04-08 08:36 Nicola Zambon Note Edited: 0036503
2011-11-19 01:59 Juha Manninen Relationship added related to 0018624
2012-09-14 19:58 Juha Manninen Relationship added related to 0022881
2013-09-03 12:07 Martin Friebe LazTarget post 1.2 => 1.4
2014-09-10 17:44 Juha Manninen LazTarget 1.4 => -
2016-05-10 23:57 Ondrej Pokorny Note Added: 0092507
2016-05-10 23:57 Ondrej Pokorny Status acknowledged => resolved
2016-05-10 23:57 Ondrej Pokorny Resolution open => fixed
2016-05-10 23:57 Ondrej Pokorny Assigned To => Ondrej Pokorny