Recent

Author Topic: Add a status bar in dll-form.  (Read 318 times)

lychee

  • Newbie
  • Posts: 3
Add a status bar in dll-form.
« on: September 17, 2019, 06:16:14 pm »
 I'm learning code form https://wiki.lazarus.freepascal.org/Form_in_DLL.
I want add a status bar in dll-form. So I modify the TDLLDialog.Create constructor.
Code: Pascal  [Select]
  1. constructor TDLLDialog.Create(aOwner: TComponent);
  2.   var
  3.     BtnShowMessage: TButton;
  4.     StatusBar1: TStatusBar;
  5.   begin
  6.     inherited CreateNew(aOwner);
  7.  
  8.     Caption := 'This form is in a DLL !!!';
  9.     Position := poWorkAreaCenter;
  10.     Width := 200;
  11.     Height := 100;
  12.  
  13.     BtnShowMessage := TButton.Create(Self);
  14.     BtnShowMessage.Parent := Self;
  15.     BtnShowMessage.Caption := 'Show message';
  16.     BtnShowMessage.AutoSize := True;
  17.     BtnShowMessage.OnClick := @BtnShowMessageClick;
  18.     StatusBar1 := TStatusBar.Create(Self);
  19.     StatusBar1.Parent := Self;
  20.   end;          
  21.  

It’s compiled ok, but run it ,I got  Failed to create win32 control, error: 1406, Why? What’s mistake did  I made?

winni

  • Sr. Member
  • ****
  • Posts: 340
Re: Add a status bar in dll-form.
« Reply #1 on: September 17, 2019, 06:40:22 pm »
Hi!

Error 1406 means that for whatever reasons Windows fails to write into the registry.
I would say: disable your anti virus software and try again.

Which Windows version? In very old versions (<= 2000) it could also be, that the registry reached the maximum size.

Winni

lychee

  • Newbie
  • Posts: 3
Re: Add a status bar in dll-form.
« Reply #2 on: September 17, 2019, 07:00:01 pm »
Hi!

Error 1406 means that for whatever reasons Windows fails to write into the registry.
I would say: disable your anti virus software and try again.

Which Windows version? In very old versions (<= 2000) it could also be, that the registry reached the maximum size.

Winni
Windows XP without  anti-virus.

FYI
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d
https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--1300-1699-

0x0000057E

ERROR_TLW_WITH_WSCHILD

Cannot create a top-level child window.

« Last Edit: September 17, 2019, 07:02:03 pm by lychee »

winni

  • Sr. Member
  • ****
  • Posts: 340

jamie

  • Hero Member
  • *****
  • Posts: 1997
Re: Add a status bar in dll-form.
« Reply #4 on: September 18, 2019, 12:35:35 am »
My Windows Help file states this..

1406L = "Error_TLW_WITH_WSCHILD"

Which means "Tool Window as a Child Window"

 normally tool windows are not childs.

 Also, I don't know if that is actually a true dialog window or a TFORM ?

 if it's a TFORM style then you need to create using CreateNew, Not Create otherwise it will be looking for resource to load in.


lychee

  • Newbie
  • Posts: 3
Re: Add a status bar in dll-form.
« Reply #5 on: September 18, 2019, 05:13:55 am »
My Windows Help file states this..

1406L = "Error_TLW_WITH_WSCHILD"

Which means "Tool Window as a Child Window"

 normally tool windows are not childs.

 Also, I don't know if that is actually a true dialog window or a TFORM ?

 if it's a TFORM style then you need to create using CreateNew, Not Create otherwise it will be looking for resource to load in.



Actually, the code from https://wiki.freepascal.org/Form_in_DLL works fine.
I just add a status bar in TDLLDialog.
Code: Pascal  [Select]
  1. StatusBar1 := TStatusBar.Create(Self);
  2. StatusBar1.Parent := Self;
  3.  
When you click 'Show modal form' button, You'll got 'Failed to create win32 control, error: 1406'.

Cyrax

  • Hero Member
  • *****
  • Posts: 755
Re: Add a status bar in dll-form.
« Reply #6 on: September 18, 2019, 08:17:23 am »
Using LCL from DLL is not supported. Maybe upcoming dynamic package support at FPC will change that.