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,

Requires Free Membership to View

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.