Recent

Author Topic: Is it possible to create ActiveX or .NET controls with Lazarus?  (Read 3037 times)

gidesa

  • Full Member
  • ***
  • Posts: 227
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #15 on: February 17, 2026, 02:53:11 pm »
Delphi automatically manages every single option, allowing you to fine-tune every single definition.
Yes, Delphi is mandatory, if you doesn't want to write the description file .IDL manually, then compile with MIDL.exe utility (included in
Visual Studio) to obtain .TLB file.
With that you only create the Type Library definitions, that can be used by any APP to "link" the OCX. But you cannot create of course the OCX.

Yes. But in Lazarus/Fpc there are some units that you can use to manually, and with big effort, create the DLL. For example comobj.pas and comserv.pas.
I done a simple example with them.
Instead Lazarus lack entirely a tool to create the TLB from scratch.

gidesa

  • Full Member
  • ***
  • Posts: 227
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #16 on: February 17, 2026, 03:05:57 pm »
I already suspected that, but it deserves mentioning as the TLB parser in importtl might be a good study object to write a initial TLB writer.

Note that TLB is a binary format, generated from the IDL textual definition (original MS COM language), or from RIDL textual format (Delphi COM language).
Instead, Importtl.exe read a TLB and create the Pascal units to call the ActiveX/COM Dll. Same as Delphi Tlibimp.exe utility.
So Importtl knows to read a TLB, but doesn't know to read an IDL and translate to TLB.

 

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12715
  • FPC developer.
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #17 on: February 17, 2026, 03:19:17 pm »
Note that TLB is a binary format, generated from the IDL textual definition (original MS COM language), or from RIDL textual format (Delphi COM language).
Instead, Importtl.exe read a TLB and create the Pascal units to call the ActiveX/COM Dll. Same as Delphi Tlibimp.exe utility.
So Importtl knows to read a TLB, but doesn't know to read an IDL and translate to TLB.

True. Note that IDL doesn't necessarily have to be the intermediate format. Also there are IDL derivates for e.g. web services (https://hexmos.com/freedevtools/man-pages/user-commands/compilers-and-assemblers/webidl2pas-3-2-2/)

gidesa

  • Full Member
  • ***
  • Posts: 227
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #18 on: February 17, 2026, 03:24:24 pm »
Note that TLB is a binary format, generated from the IDL textual definition (original MS COM language), or from RIDL textual format (Delphi COM language).
Instead, Importtl.exe read a TLB and create the Pascal units to call the ActiveX/COM Dll. Same as Delphi Tlibimp.exe utility.
So Importtl knows to read a TLB, but doesn't know to read an IDL and translate to TLB.

True. Note that IDL doesn't necessarily have to be the intermediate format. Also there are IDL derivates for e.g. web services (https://hexmos.com/freedevtools/man-pages/user-commands/compilers-and-assemblers/webidl2pas-3-2-2/)

Yes. Only needs a translator from <whatever COM description language> to binary TLB.  IDL is the original MS.

LeP

  • Full Member
  • ***
  • Posts: 204
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #19 on: February 17, 2026, 03:32:17 pm »
Like @Marcov said, the description of TLB is made by IDL metadata and Delphi act this with RIDL ((Restricted Interface Definition Language) parser.

I always used the RIDL integrated editor, and I never have big issues. And that editor is still capable to maintain alignment from TLB source (intermediate file) and RIDL file (and viceversa).
This means that you can modifiy the TLB source (that is an intermediate file in Pascal) and align the RIDL.

I have done this somtimes to manually adapt the TLB for use it in 32 bit source and in the 64 bit source with some $IFDEF, to distribuite only one TLB source file.

This is a piece of RIDL:
Code: Text  [Select][+][-]
  1. // ************************************************************************ //
  2. // WARNING
  3. // -------
  4. // This file is generated by the Type Library importer or Type Library Editor.
  5. // Barring syntax errors, the Editor will parse modifications made to the file.
  6. // However, when applying changes via the Editor this file will be regenerated
  7. // and comments or formatting changes will be lost.
  8. // ************************************************************************ //
  9. // File generated on 17/02/2026 15:28:56 (- $Rev: 12980 $, 6627000).
  10.  
  11. [
  12.   uuid(F6E13887-40C9-43E8-B34A-51BEDE845417),
  13.   version(1.0),
  14.   control
  15.  
  16. ]
  17. library ProjectEsplora
  18. {
  19.  
  20.   importlib("stdole2.tlb");
  21.  
  22.   interface IFormEsplora;
  23.   dispinterface IFormEsploraEvents;
  24.   coclass FormEsplora;
  25.  
  26.  
  27.   [
  28.     uuid(C9BCB47B-FED3-4A16-8BFD-F39A045053B7)
  29.   ]
  30.   enum TxActiveFormBorderStyle
  31.   {
  32.     [helpstring("afbNone")]
  33.     afbNone = 0,
  34.     [helpstring("afbSingle")]
  35.     afbSingle = 1,
  36.     [helpstring("afbSunken")]
  37.     afbSunken = 2,
  38.     [helpstring("afbRaised")]
  39.     afbRaised = 3
  40.   };
  41.  
  42.   [
  43.     uuid(D057A1E5-036A-4AEF-AB13-64BDC4C251AD)
  44.   ]
  45.   enum TxPrintScale
  46.   {
  47.     [helpstring("poNone")]
  48.     poNone = 0,
  49.     [helpstring("poProportional")]
  50.     poProportional = 1,
  51.     [helpstring("poPrintToFit")]
  52.     poPrintToFit = 2
  53.   };
  54.  

and this is a piece of TLB:

Code: Pascal  [Select][+][-]
  1. unit ProjectEsplora_TLB;
  2.  
  3. // ************************************************************************ //
  4. // WARNING
  5. // -------
  6. // The types declared in this file were generated from data read from a
  7. // Type Library. If this type library is explicitly or indirectly (via
  8. // another type library referring to this type library) re-imported, or the
  9. // 'Refresh' command of the Type Library Editor activated while editing the
  10. // Type Library, the contents of this file will be regenerated and all
  11. // manual modifications will be lost.
  12. // ************************************************************************ //
  13.  
  14. // $Rev: 52393 $
  15. // File generated on 13/12/2016 22:47:27 from Type Library described below.
  16.  
  17. // ************************************************************************  //
  18. // Type Lib: C:\Users\...................)
  19. // LIBID: {F6E13887-40C9-43E8-B34A-51BEDE845417}
  20. // LCID: 0
  21. // Helpfile:
  22. // HelpString:
  23. // DepndLst:
  24. //   (1) v2.0 stdole, (C:\Windows\SysWOW64\stdole2.tlb)
  25. // SYS_KIND: SYS_WIN32
  26. // ************************************************************************ //
  27. {$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
  28. {$WARN SYMBOL_PLATFORM OFF}
  29. {$WRITEABLECONST ON}
  30. {$VARPROPSETTER ON}
  31. {$ALIGN 4}
  32.  
  33. interface
  34.  
  35. uses Winapi.Windows, System.Classes, System.Variants, System.Win.StdVCL, Vcl.Graphics, Vcl.OleCtrls, Winapi.ActiveX;
  36.  
  37.  
  38. // *********************************************************************//
  39. // GUIDS declared in the TypeLibrary. Following prefixes are used:
  40. //   Type Libraries     : LIBID_xxxx
  41. //   CoClasses          : CLASS_xxxx
  42. //   DISPInterfaces     : DIID_xxxx
  43. //   Non-DISP interfaces: IID_xxxx
  44. // *********************************************************************//
  45. const
  46.   // TypeLibrary Major and minor versions
  47.   ProjectEsploraMajorVersion = 1;
  48.   ProjectEsploraMinorVersion = 0;
  49.  
  50.   LIBID_ProjectEsplora: TGUID = '{F6E13887-40C9-43E8-B34A-51BEDE845417}';
  51.  
  52.   IID_IFormEsplora: TGUID = '{BFAD198F-0F3C-4DCD-A8A0-3DA2E1EB2F4B}';
  53.   DIID_IFormEsploraEvents: TGUID = '{28572D01-6B67-4B45-A07A-C233D0C62EA1}';
  54.   CLASS_FormEsplora: TGUID = '{DBC913F0-A433-4F5C-AFC9-A2502A2E1AC0}';
  55.  
  56. // *********************************************************************//
  57. // Declaration of Enumerations defined in Type Library
  58. // *********************************************************************//
  59. // Constants for enum TxActiveFormBorderStyle
  60. type
  61.   TxActiveFormBorderStyle = TOleEnum;
  62. const
  63.   afbNone = $00000000;
  64.   afbSingle = $00000001;
  65.   afbSunken = $00000002;
  66.   afbRaised = $00000003;
  67.  
  68. // Constants for enum TxPrintScale
  69. type
  70.   TxPrintScale = TOleEnum;
  71. const
  72.   poNone = $00000000;
  73.   poProportional = $00000001;
  74.   poPrintToFit = $00000002;
  75.  

LeP

  • Full Member
  • ***
  • Posts: 204
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #20 on: February 17, 2026, 03:56:23 pm »
Note that TLB is a binary format, generated from the IDL textual definition (original MS COM language), or from RIDL textual format (Delphi COM language).
Instead, Importtl.exe read a TLB and create the Pascal units to call the ActiveX/COM Dll. Same as Delphi Tlibimp.exe utility.
So Importtl knows to read a TLB, but doesn't know to read an IDL and translate to TLB.
True. Note that IDL doesn't necessarily have to be the intermediate format. Also there are IDL derivates for e.g. web services (https://hexmos.com/freedevtools/man-pages/user-commands/compilers-and-assemblers/webidl2pas-3-2-2/)
Yes. Only needs a translator from <whatever COM description language> to binary TLB.  IDL is the original MS.

This is done from Delphi with GENTLB utility, that from RIDL file can generate:

Code: Text  [Select][+][-]
  1. Syntax: GenTLB [options] <sourcefile>
  2.  
  3.  TLB Output File Options:
  4.     -T<name>   Name of typelibrary output file
  5.     -D<path>   Output directory path
  6.  
  7.  Additional Language Binding files to generate:
  8.   -C  Generate C++ Binding file
  9.   -P  Generate PASCAL Binding file

But the editor of Delphi (that use TLibImp like @gidesa said) have more power, and can add directly the full object class (OleCOntrol) compatible with the normal Class used in Pascal without any manual intervention.

gidesa

  • Full Member
  • ***
  • Posts: 227
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #21 on: February 17, 2026, 04:04:03 pm »
and this is a piece of TLB:

Code: Pascal  [Select][+][-]
  1. unit ProjectEsplora_TLB;
  2. ................
  3.  

This is not the .TLB, it's the translation from .TLB to a Pascal unit for calling the COM.
The file with .TLB extension is a binary file, language agnostic.
I think it's important to clarify details for who has never used COM.

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #22 on: February 17, 2026, 04:30:52 pm »
So isn't there in D12 ActiveX projects in New Project?
There is this:
- "ActivaX Library"
- "Type Library"

But there is no this, as in D7:
- "ActiveX Control"
- "ActiveX Form"
- "Automation Object"
- and much, much more
I may seem rude - please don't take it personally

LeP

  • Full Member
  • ***
  • Posts: 204
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #23 on: February 17, 2026, 04:46:54 pm »
This is not the .TLB, it's the translation from .TLB to a Pascal unit for calling the COM.
The file with .TLB extension is a binary file, language agnostic.
I think it's important to clarify details for who has never used COM.

THIS IS, like provious described, an TLB SOURCE INTERMEDIATE FILE made in Pascal. It "connect" IDL (or better RIDL) metadata to Pascal "usable" file. You (only with Delphi IDE) can modify TLB pas file and generate tlb binary file. This TLB PAS file is generated with GENTLB utility (if you hav a ridl file) or directly from Delphi IDE. This pas file is the file that implemented interfaces needed to Delphi to connect the real source where you put controls, events, procedure, and what you needs to tlb binary file.
Take care that tlb binary file is not needed at all, Delphi can use simply the ridl file and the tlb pas file with your sources to build to AciveX exe (in varoius form like exe, dll, ocx).

So isn't there in D12 ActiveX projects in New Project?
There is this:
- "ActivaX Library"
- "Type Library"

But there is no this, as in D7:
- "ActiveX Control"
- "ActiveX Form"
- "Automation Object"
- and much, much more

You must create an ActiveX Library and then you will see the other controls.
« Last Edit: February 17, 2026, 06:19:36 pm by LeP »

gidesa

  • Full Member
  • ***
  • Posts: 227
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #24 on: February 17, 2026, 05:14:22 pm »
THIS IS, like provious described, an TLB SOURCE INTERMEDIATE FILE made in Pascal. It "connect" IDL (or better RIDL) metadata to Pascal "usable" file. You (only with Delphi IDE) can modify TLB pas file and generate tlb binary file.

Nope. You cannot change RIDL file modifying only the .PAS .
Inverse, you can change RIDL and obtain a modified .PAS .
RIDL is always the origin.


LeP

  • Full Member
  • ***
  • Posts: 204
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #25 on: February 17, 2026, 06:17:26 pm »
Nope. You cannot change RIDL file modifying only the .PAS .
Inverse, you can change RIDL and obtain a modified .PAS .
RIDL is always the origin.
Yes, you are right. I manually changed the TLB pas file from imported library for the app that use the ActiveX.
The TLB pas file generated from RIDL is generated (and overwrited) every time you modify the RIDL file.

Sorry, my fault an explanation.

LeP

  • Full Member
  • ***
  • Posts: 204
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #26 on: February 17, 2026, 11:20:42 pm »
Attached is a simple example of ActiveX made with Delphi, with one image of IDE and run test program (Unit6 on the right side of IDE).

P.S.: those are the Delphi sources, someone should try to convert them for Lazarus.
« Last Edit: February 17, 2026, 11:28:35 pm by LeP »

gidesa

  • Full Member
  • ***
  • Posts: 227
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #27 on: February 18, 2026, 12:32:25 pm »
Attached is a simple example of ActiveX made with Delphi, with one image of IDE and run test program (Unit6 on the right side of IDE).

P.S.: those are the Delphi sources, someone should try to convert them for Lazarus.

Thank you. I tried to compile with Fpc, but the unit OleCtrls is missing. So Ole controls are not supported.

LeP

  • Full Member
  • ***
  • Posts: 204
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #28 on: February 18, 2026, 03:11:19 pm »
Attached is a simple example of ActiveX made with Delphi, with one image of IDE and run test program (Unit6 on the right side of IDE).
P.S.: those are the Delphi sources, someone should try to convert them for Lazarus.
Thank you. I tried to compile with Fpc, but the unit OleCtrls is missing. So Ole controls are not supported.

May be you must Install LazActiveX package from Install/Uninstall Package menu.

After that you'll see an ActiveX container component. I think that you must explore ActiveXContainer.pas and use IOleCOntrol or something else and modify the Delphi code.
The big issue the I see is that Delphi ActiveX has a lot of properties / procedures and functions to replicate (I think) and to act at design time like a normal Windows control.

If this is not present in Lazarus, lot of code should be write.

 

TinyPortal © 2005-2018