Professional Documents
Culture Documents
Active X
Active X
By Kris Golko
I recall the day when I saw Delphi 3 presented for the first
time. I remember it as if it was yesterday. The presenter
was so excited about ActiveX control creation but the
audience didnt seem very interested in this subject. It looked
so far away from the development problems of my
experience. Now I work in a mixed Delphi/C++ environment
and creating ActiveX controls in Delphi and handing them
over to the C++ guys is an ideal solution. I can say now that
it really can be done, but there are some limitations and
some things you should know before you start.
Delphi versions
ActiveX control creation was introduced with Delphi 3. The
Inprise development team did a terrific job here (apparently)
to no avail, as I suspect that only a few people tried it in
those days. Delphi 4 offers vital improvements in this area.
Delphi 5 offers just a few improvements over Delphi 4, but
Ive heard complaints from Delphi 4 users about the stability
of the Type Library Editor, so Ive been using Delphi 5 and I
would recommend it (at least if somebody is interested in
ActiveX stuff).
How to use it
When you have finally compiled the control successfully,
you need to register it to the system (Windows Registry).
You can do it from the Delphi IDE Run|Register ActiveX
Server, or using TRegSvr.exe utility bundled with Delphi, or
regsvr32.exe bundled with MS Windows.
Once your control is registered, you can test it in a
development tool, like Visual Basic, Visual C++, C++Builder
and, of course, Delphi. To use it with Delphi, you need to
install it on a component palette (you can do it by selecting
Component|Import ActiveX Control). Delphi will place the
control on the ActiveX tab and will translate the controls
type library (stored as a resource in the controls OCX file)
into an Object Pascal unit. This Pascal unit will be placed by
default in the imports directory (something like
\Delphi5\Imports). Note that, although the unit is also called
CONTROLNAME_TLB and also contains the same
information, this is a completely different unit. It is not subject
to change: if the control has changed you need to uninstall it
and reimport it to ensure the changes are reflected.
Changes
One of the biggest disadvantages of ActiveX control creation
in Delphi is making changes. Its easy if you dont have to
change the type library; just change the VCL component
code and recompile everything. If you want to make changes
to the type library, you have to be absolutely sure you know
what youre doing. Change the type library using Type Library
Final thoughts
ActiveX controls can really be created by Delphi, although
with a little bit of drudgery
Wizards provide simple solutions for a start, but you have to
find your own way of understanding the complexities of COM
technologies.
Working with COM in Delphi can be a good preparation for
working with CORBA. These two have a lot in common,
especially in Delphi.