Creating ActiveX controls with Delphi

Developer Tip: Creating ActiveX controls with Delphi

Creating ActiveX controls with Delphi

Many hardcore Delphi developers never tire of arguing the merits of VCL components over ActiveX controls. Regardless of your own view, one thing's for sure; you shouldn't allow your preferences to limit your market share. Consider offering your customers both VCL and ActiveX versions.

In his book, Delphi COM Programming (published by MacMillan Technical Publishing), Eric Harmon explains why you should consider converting your VCL to ActiveX, along with clear step-by-step instructions on how to accomplish the conversion.

Creating ActiveX Controls
In this section, I'll show you how to create an ActiveX control from an existing Delphi component. In Delphi, you take an existing visual control (derived from TWinControl) and turn it into an ActiveX control. This means that you can write and test a VCL component completely in Delphi before taking the plunge and creating the ActiveX control.

Reasons to Create ActiveX Controls
With all the capability of the VCL, why should you create an ActiveX control? For one very good reason: You want your control to be usable by all the developers out there who aren't using Delphi. By far, the largest market for ActiveX controls is the Visual Basic market.

Converting a VCL Component to an ActiveX Control
For purposes of illustration, let's convert the TCheckListBox component into an ActiveXcontrol. To do this, execute the following steps:

  1. From the Delphi main menu, select File, New. The Object Repository is displayed.

  2. On the ActiveX page, select ActiveX Library and click OK.

  3. Select File, New again, and select the ActiveX Control icon from the menu.

  4. ActiveX page of the Object Repository. The ActiveX Control Wizard appears.

  5. From the VCL Class Name combo box, select the VCL component to convert to an ActiveX control.

When you select TCheckListBox in the combo box, the ActiveX Control Wizard automatically generates default values for the ActiveX control name, Implementation unit, Project name, and Threading model.

You should always leave the threading model set to tmApartment, as it is required for ActiveX controls used by Visual Basic.

---------------------------

To learn more, check out the book Delphi COM Programming, published by MacMillan Technical Publishing and available from New Riders

.
This was first published in July 2000

Dig deeper on Windows Operating System Management

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchServerVirtualization

SearchCloudComputing

SearchExchange

SearchSQLServer

SearchWinIT

SearchEnterpriseDesktop

SearchVirtualDesktop

Close