Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-05

ActiveX control demo

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ludo Brands

Dear all,

Attached a demo program that implements a simple solution for embedding ActiveX controls in LCL forms.
It uses atl.dll, part of Active Template Library, the MS C++ COM support classes. The dll is part of most (if not all) windows installations and is really lightweight (58k on win32, 88k on win64).
If using MS C++ class helpers is causing "religuous" objections, please don't read on ;)

The method used is quite simple:
- Drop a Tpanel on a form. Could be any visual control but Tpanel is the simplest.
- Start ActiveX control using CreateOleObject (late binding) or CoCreateInstance (early binding)
- call AtlAxAttachControl with Tpanel.Handle and the IUnknown interface of the ActiveX object.
That's it. The ActiveX object is embedded in the Tpanel. Resizing the Tpanel at runtime correctly resizes the ActiveX control and setting Tpanel.Visible to false will hide the ActiveX control.

I also added the code to implement an event sink for the ActiveX object. The demo uses the web browser control. The status bar below the control is updated by the event sink.

Important: since the fpc COM implementation has changed quit a lot recently, the demo needs a recent fpc to compile and run. So if you get the compiler complaining about constref in QueryInterface or if you run into compile or run-time errors around Utf8Encode(OleVariant(Params.rgvarg[0])); , update the compiler.

Ludo

-------------- next part --------------
A non-text attachment was scrubbed...
Name: demoAX.zip
Type: application/x-zip-compressed
Size: 4837 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110530/d9e7b3e4/attachment.bin>

Reply by email

Roberto Padovani
to Ludo Brands

Until this morning I was using 0.9.28.3, so I decided that it was time to upgrade.

After installing lazarus 0.9.30 from sourceforge and opening your demo I get a missing required package LCL >= 1.0.1.
By default I found the installed package LCL 1.0 and not installed LCL 0.9.30, which I cannot install because it makes conflict with the other one.

Happened to anyone ?

R#

2011/5/30 Ludo Brands :

Show quoted text 42 lines
Dear all, Attached a demo program that implements a simple solution for embedding ActiveX controls in LCL forms. It uses atl.dll, part of Active Template Library, the MS C++ COM support classes. The dll is part of most (if not all) windows installations and is really lightweight (58k on win32, 88k on win64). If using MS C++ class helpers is causing "religuous" objections, please don't read on ;) The method used is quite simple: - Drop a Tpanel on a form. Could be any visual control but Tpanel is the simplest. - Start ActiveX control using CreateOleObject (late binding) or CoCreateInstance (early binding) - call AtlAxAttachControl with Tpanel.Handle and the IUnknown interface of the ActiveX object. That's it. The ActiveX object is embedded in the Tpanel. Resizing the Tpanel at runtime correctly resizes the ActiveX control and setting Tpanel.Visible to false will hide the ActiveX control. I also added the code to implement an event sink for the ActiveX object. The demo uses the web browser control. The status bar below the control is updated by the event sink. Important: since the fpc COM implementation has changed quit a lot recently, the demo needs a recent fpc to compile and run. So if you get the compiler complaining about constref in QueryInterface or if you run into compile or run-time errors around Utf8Encode(OleVariant(Params.rgvarg[0])); , update the compiler. Ludo -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Mattias Gaertner
to Roberto Padovani

?
?

Roberto Padovani hat am 30. Mai 2011 um 16:37
geschrieben:

Show quoted text 10 lines
Until this morning I was using 0.9.28.3, so I decided that it was time to upgrade. After installing lazarus 0.9.30 from sourceforge and opening your demo I get a missing required package LCL >= 1.0.1. By default I found the installed package LCL 1.0 and not installed LCL 0.9.30, which I cannot install because it makes conflict with the other one. Happened to anyone ??

Open the .lpi file, search "LCL".
?
<PackageName Value="LCL"/>
?
Delete any version requirement you find.?
?

Mattias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110530/ee8c977f/attachment.html>

Reply by email

Roberto Padovani
to Mattias Gaertner

2011/5/30 Mattias Gaertner :

Show quoted text 42 lines
Roberto Padovani hat am 30. Mai 2011 um 16:37 geschrieben: > Until this morning I was using 0.9.28.3, so I decided that it was time > to upgrade. > > After installing lazarus 0.9.30 from sourceforge and opening your demo > I get a missing required package LCL >= 1.0.1. > By default I found the installed package LCL 1.0 and not installed LCL > 0.9.30, which I cannot install because it makes conflict with the > other one. > > Happened to anyone ? Open the .lpi file, search "LCL". <PackageName Value="LCL"/> Delete any version requirement you find. Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

After cleaning all my lazarus installation and with a newer 0.9.31 (r30999) it works fine.

Roberto

Reply by email