Recent

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

CM630

  • Hero Member
  • *****
  • Posts: 1641
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Is it possible to create ActiveX or .NET controls with Lazarus?
« on: October 20, 2020, 07:58:44 am »
Hi, I would like to use some Lazarus controls in LabView. LabView supports .NET and ActiveX controls, it does not seem to support COM controls.
Is it possible to create a .NET or ActiveX control with Lazarus? Or maybe I should create a .NET control and wrap it somehow in .NET?
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

PascalDragon

  • Hero Member
  • *****
  • Posts: 6354
  • Compiler Developer
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #1 on: October 20, 2020, 09:28:34 am »
The way to go would be ActiveX controls (ActiveX controls are COM controls, there are no specific COM controls), however Lazarus currently does not provide any wizards to generate the necessary boilerplate code and thus it is probably not tested how well it would work. You could try to generate the necessary boilerplate code using a Community Edition of Delphi and then use that with Lazarus, however your mileage may vary.

PascalDragon

  • Hero Member
  • *****
  • Posts: 6354
  • Compiler Developer
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #2 on: October 21, 2020, 09:30:35 am »
I've looked at what Delphi does and it turns out that it requires quite some code to get this working correctly.

So maybe your best bet would indeed be a simple .NET library that calls a Lazarus library...

CM630

  • Hero Member
  • *****
  • Posts: 1641
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #3 on: February 17, 2026, 07:32:46 am »
A few years later, maybe there is some improvement in that direction?
Maybe it has become easier to use sth. like Eye Candy Controls on a Vb form in MS Office?
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #4 on: February 17, 2026, 11:22:31 am »
I am also interested in this topic

I was looking for source code in C to gain a deeper understanding of how it works, and in Delphi

But so far, I haven't found the time to try to make even a minimal simple example, a basis. Based on this, other more interested (or more time-rich) people could develop their ideas and research
I may seem rude - please don't take it personally

LeP

  • Full Member
  • ***
  • Posts: 202
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #5 on: February 17, 2026, 12:00:05 pm »
To create an ActiveX control (i.e., a more or less graphical control that runs in the space of another process), Delphi uses several techniques: from the RIDL descriptor to then generate the appropriate TLB, and obviously to the link with the operating system.
Obviously, all methods, properties, fields, and so on must comply with the Microsoft COM standard.
Delphi automatically manages every single option, allowing you to fine-tune every single definition.
In the past, I worked extensively on developing complex COM objects for third-party integration (often in C#) because with Delphi, it was relatively simple and effective.
Furthermore, having "very fine-grained" control in Delphi allowed me to update the component with new features while maintaining perfect compatibility with older applications.

If you need some advice (unless someone has already developed some tools in FPC/Lazarus), use Delphi CE to develop something and then try porting it to Lazarus/FPC. Maintenance can then be done manually directly in Lazarus; it involves copying/editing individual fields in the TLB file(s).

Microsoft has significantly advanced the technology, introducing SXS (side-by-side), which allows you to use the ActiveX component without even having to register it.
For ActiveX (called "in-process"), the component must be developed with the same technology (64-bit for 64-bit apps and 32-bit for 32-bit apps), while for COM technology (called "out-process"), you can develop a server (that's what it's called in technical terms) with any technology and use it with any app.

This is summarized in a nutshell.

I don't currently know how actively Microsoft supports ActiveX and COM.

LeP

  • Full Member
  • ***
  • Posts: 202
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #6 on: February 17, 2026, 12:15:25 pm »
 
But so far, I haven't found the time to try to make even a minimal simple example, a basis. Based on this, other more interested (or more time-rich) people could develop their ideas and research

I can post very quickly a simple ActiveX component and a Test prject that use it made with Delphi. Anyone that have more skills with FPC / Lazarus can work on.
I can post it also the gen. to work with SxS so you don't need to register the component created (.ocx).

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 404
  • I use FPC [main] 💪🐯💪
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #7 on: February 17, 2026, 12:26:06 pm »
I can post very quickly a simple ActiveX component and a Test prject that use it made with Delphi. Anyone that have more skills with FPC / Lazarus can work on.
I can post it also the gen. to work with SxS so you don't need to register the component created (.ocx)

I think this could be useful

(by the way, I couldn't find a way to create an ActiveX component in D12.1CE. I wonder which version of Delphi removed this feature (or maybe it's only missing in the Community Edition))
I may seem rude - please don't take it personally

gidesa

  • Full Member
  • ***
  • Posts: 227
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #8 on: February 17, 2026, 12:26:59 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.
Quote
I don't currently know how actively Microsoft supports ActiveX and COM.

Support in last version of Visual Studio is more and more reduced. Microsoft promote Net, no more COM/ActiveX.

gidesa

  • Full Member
  • ***
  • Posts: 227
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #9 on: February 17, 2026, 12:31:17 pm »
(by the way, I couldn't find a way to create an ActiveX component in D12.1CE. I wonder which version of Delphi removed this feature (or maybe it's only missing in the Community Edition))

So isn't there in D12 ActiveX projects in New Project?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12710
  • FPC developer.
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #10 on: February 17, 2026, 01:26:07 pm »
FPC also has a OCX extractor, Importtl .

Quote
Usage:  importtl [options] file
Reads type information from "file" and converts it into a freepascal binding
units.
Options.
  -h    : displays this text.
  -a    : create ActiveXContainer descendants
  -d dir: set output directory. Default: current directory.
  -n    : do not recurse typelibs. Default: create bindings for all
          dependencies.
  -p    : create lazarus package for ActiveXContainer descendants
  -t    : remove "tag" prefix from structs
  --ref-style st : input parameter style, parameter st=var,constref
            or constrefdelphi (= XE3+ const [ref])

I assume however that is for already created typelibs of external package, not for ones that are being created from scratch.

LeP

  • Full Member
  • ***
  • Posts: 202
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #11 on: February 17, 2026, 01:52:55 pm »
I assume however that is for already created typelibs of external package, not for ones that are being created from scratch.
Yes, one thing is a TLB Pascal file (a wrapper), that can be used by any Pascal APP an another is "how" the source code of ActiveX (that is a binary file like an EXE, OCX, DLL) is made.

LeP

  • Full Member
  • ***
  • Posts: 202
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #12 on: February 17, 2026, 02:06:43 pm »
(by the way, I couldn't find a way to create an ActiveX component in D12.1CE. I wonder which version of Delphi removed this feature (or maybe it's only missing in the Community Edition))

So isn't there in D12 ActiveX projects in New Project?
It should be. From RAD features matrix COM/ActiveX support (use and creation) is enabled in CE.

LeP

  • Full Member
  • ***
  • Posts: 202
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #13 on: February 17, 2026, 02:19:58 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.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12710
  • FPC developer.
Re: Is it possible to create ActiveX or .NET controls with Lazarus?
« Reply #14 on: February 17, 2026, 02:26:59 pm »
I assume however that is for already created typelibs of external package, not for ones that are being created from scratch.
Yes, one thing is a TLB Pascal file (a wrapper), that can be used by any Pascal APP an another is "how" the source code of ActiveX (that is a binary file like an EXE, OCX, DLL) is made.

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.

I assume the first step would be to have a datastructure to operate on, and an editor.  Maybe the dataformat and persistence of the editor should not be the TLB itself, as that is what Delphi did, and it was plagued by bugs for years (probably because it couldn't store Pascal specific metadata anywhere).  That would also allow this intermediate dataformat to be text.

Any comments, how do other toolchains handle this ?

 

TinyPortal © 2005-2018