Importing ActiveX in Delphi 2005

Question

Importing ActiveX in Delphi 2005

Answer

Actually this problem can occur with OCX controls which have been written using Visual Basic (VB).

You can solve this problem by doing the following in Delphi:

1. Select File, Open
2. Change file type to "Type Library"
3. Select the ocx which you want to import.
4. After a long pause this opens the Type Library Editor. Click on the name of the control at the top of the tree in the left-hand window.
5. Click on "Flags" on the right-hand panel so that there is a tick in 'Control'.
6. Now click on the name of the control which appears part way down the tree (not the one that begins with an underscore). Click on the check box that says "Can Create" so that it is checked.
7. Select File, Save As from the Delphi menu and save the newly created type library to C:\Program Files\Borland\delphi (your version)\Imports
8. Save the file as your ocx's name but with an extension of .tlb - for example myfabocx.tlb
9. Select Project, Import Type Library
10. Import the myfabocx.tlb file that you saved earlier. Don't forget to choose the name of the pallette page it will appear in.
11. Make sure you say NO to overwriting the tlb that already exists and make sure "create component wrapper" is ticked.


You should now see the OCX has been created on the component pallette page that you selected in step 10. From that point on you can use the control as if it was a VCL component.

If you distribute your application you need to put the OCX in the same directory as your exe and then run "regsvr32 myfabocx.ocx" to register it BEFORE your Delphi application can run.