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>
