Working with ActiveX Controls in Delphi 5

I have a number of ActiveX controls that I have written in Delphi 5.  These things have been stable for so long that when I had to make a change to one recently, I found that I had completely forgotten how to re-import the control into the Delphi IDE.  It’s not that this is difficult to do but it is a tad obscure.  So, just in case I forget how to do it again, I am going to document the procedure here.

When you are working with the ActiveX project itself, there are usually no problems.  Everything you need to compile it is usually right in the project directory.  The only thing that you might want to do from this project is unregister or register the control with Windows.  Delphi provides two menu items that make this quick and easy.  To register your ActiveX control with Windows select Run | Register ActiveX Server.  To unregister your control, select Run | Unregister ActiveX Server.  Once you have registered your control the first time you will not need to worry about this unless you change the location of the .OCX file for some reason.

When you are working with the client project (the program that uses the ActiveX control) you need to concerned with keeping the client in sync with the control.

When you first start working on the client program you have to import the ActiveX control into the Delphi IDE.  You do  this by selecting Component | Import ActiveX Control from the IDE’s menu.  As time goes on you will inevitably need to make changes to the control’s interface.  For example, adding new methods or properities.  The Delphi IDE needs to be notified of any such changes before the client can make use of the new features.  This is what I find to be the obscure bit. To update the IDE you need to remove the control from the IDE and then reimport it.  To remove the control from the IDE you select Component | Install Packages from the menu.  You then need to find the package that contains your control.  If you accepted the defaults when you imported it (like I did) the package that you want is Borland User Components.  Highlight this package and click the Edit button.  When the new dialogue appears click the Remove button.  When the next dialogue appears, highlight your control and click OK. Then click the Compile button to recompile the package and remove your component from the IDE.  Once this is done, simply reimport your control and you should be off to the races.

Leave a Reply