Recent

Author Topic: LCL and DLLs, initializing the widget set safely?  (Read 6196 times)

marco_gamelix

  • Newbie
  • Posts: 4
LCL and DLLs, initializing the widget set safely?
« on: December 08, 2009, 01:25:30 pm »
I'm trying to create a dll with an LCL form, and found that is not working. After looking around I found several posts that say LCL is not working in DLL, like: http://www.mail-archive.com/lazarus@miraclec.com/msg16490.html

I traced down the problem, and it seems the widget set is not being initialized in the DLL. While debbuging I got this:

---------------------------------------------
TWinControl.GetHandle Creating handle on the fly: :TForm1
WARNING:[TWinControl.HandleNeeded] creating handle for TForm1 while destroying handles!
[TWinControl.CreateWnd] START :TForm1
TWinControl.CreateWnd (V)TWin32WSCustomForm :TForm1
FinishCreateWindow :: CreateWindowEx pClassName=Window, WindowTitle=
Failed to create win32 control, error: 1407 : No se ha encontrado la clase de ventana.
[FORMS.PP] ExceptionOccurred
  Sender=Exception
  Exception=Failed to create win32 control, error: 1407 : No se ha encontrado la clase de ventana.
  Stack trace:
  $1011936D  FINISHCREATEWINDOW,  line 226 of win32wscontrols.pp
TApplication.HandleException Failed to create win32 control, error: 1407 : No se ha encontrado la clase de ventana.
  Stack trace:
  $1011936D  FINISHCREATEWINDOW,  line 226 of win32wscontrols.pp
---------------------------------------------

According to that, there is an exception at win32wscontrols.pp, function FinishCreateWindow(), because CreateWindow() is being called without registering the window class. And that function is called when trying to resolve the window's handle.

I found that applications register the window class with calls to TApplication.Initialize() ->  WidgetSet.AppInit() -> WinRegister()

Without knowledge of LCL's internals, I tried to call those methods and functions from the DLL's initialization section, but it didn't work. The exception was gone, but the DLL still failed and broke the debug information. Could someone with knowledge of the LCL tell if it's possible to initialize the widget set in the DLL, and how should that be done to be safely?

Regards!
-Marco

 

TinyPortal © 2005-2018