Recent

Author Topic: How can Lazarus LCL components be accessed in a DLL?  (Read 4580 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1160
    • HowTos Considered Harmful?
How can Lazarus LCL components be accessed in a DLL?
« on: September 16, 2014, 03:35:12 am »
How can Lazarus LCL components be accessed in a DLL?

How is a Lazarus program designed to make UI controls available in a DLL, so that another language (most likely an interprter) can use them ?
« Last Edit: September 16, 2014, 04:23:27 am by vfclists »
Lazarus 3.0/FPC 3.2.2

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How can Lazarus LCL components be accessed in a DLL?
« Reply #1 on: September 16, 2014, 04:41:06 am »
simple answer you have to wrap them in containers that the other language can unsderstand. if it is interpret it then it probably has some kind of api that you can attach to it from outside or some kind of c level understanding of external libraries, find out what it is exactly and then wrap the in such a maner to allow it to use them
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

vfclists

  • Hero Member
  • *****
  • Posts: 1160
    • HowTos Considered Harmful?
Re: How can Lazarus LCL components be accessed in a DLL?
« Reply #2 on: September 16, 2014, 11:02:57 am »
simple answer you have to wrap them in containers that the other language can unsderstand. if it is interpret it then it probably has some kind of api that you can attach to it from outside or some kind of c level understanding of external libraries, find out what it is exactly and then wrap the in such a maner to allow it to use them

Are there any examples of what you are describing out there, in the wild?
Lazarus 3.0/FPC 3.2.2

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12657
  • FPC developer.
Re: How can Lazarus LCL components be accessed in a DLL?
« Reply #3 on: September 16, 2014, 11:17:08 am »
How can Lazarus LCL components be accessed in a DLL?

Only through hackery, no supported solutions.

Quote
How is a Lazarus program designed to make UI controls available in a DLL, so that another language (most likely an interprter) can use them ?

Not. On Windows you might be able to create activex components, but that is also still in its infancy (and often requires FPC 2.7.x)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How can Lazarus LCL components be accessed in a DLL?
« Reply #4 on: September 16, 2014, 12:54:13 pm »
simple answer you have to wrap them in containers that the other language can unsderstand. if it is interpret it then it probably has some kind of api that you can attach to it from outside or some kind of c level understanding of external libraries, find out what it is exactly and then wrap the in such a maner to allow it to use them

Are there any examples of what you are describing out there, in the wild?

not that I know off but what I describe is something along the lines off
Code: [Select]
  TMyClass = Class(Tpersistent)
   private
     FColor : TColor;
  Public
     Procedure RepaintNewColor;
  published
    Property PrettyColor:TColor read FColor Write FColor
  end;

procedure CreateMyClass(out NewClass:Pointer);
begin
  NewClass := TMyClass.Create;
end;
procedure SetPRettyColor(aClass:Pointer; NewColor:Int32);
begin
  TMyClass(aClass).PrettyColor := TColor(NewColor);
end;
Function GetPrettyColor(aClass:Pointer):Int32;
begin
  REsult := TMyClass(aClass).PrettyColor;
end;
Procedure MyClassRepaintNewColor(aClass:Pointer);
begin
   TMyClass(aClass).RepaintNewColor;
end;

Now you have flatten controls out in to something that could be callable from C give it some appropriate calling convention like stdcall cdecl etc and you are set to start working on anything that can consume C code.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018