An approach to creating ActiveX control in ATL based on VC + +

Source: Internet
Author: User
Tags inheritance ole requires

Introduction

ActiveX control is a powerful program design and development technology provided by Microsoft, and is an important part of COM component Development technology. It is the third version of OLE, and the largest expansion of the original OLE control is the addition of Internet functionality, which can be used not only in containers that support OLE controls, but also as an Internet control that is directly part of a Web page. In addition, the ActiveX control acts as a reusable component, which is the equivalent of a packaged code module that communicates with the application through its methods, properties, events, and, in addition, ActiveX controls that are not related to the development language. Users do not have to consider the control when it is VC or VB and other languages developed, the application is through COM and control communication. Visible, ActiveX controls can be used on any software platform that supports ActiveX controls, enabling controls that are developed by different vendors to actually assemble together, making the software's production process similar to the assembly process of various plug-ins in the hardware industry, enabling the software to industrialize, Greatly reduces the software development cost, greatly enhances the software production efficiency, realizes the software resources sharing.

ATL technology

1) ATL

ATL is an abbreviation for the ActiveX Template Library, which is a set of C + + template libraries. Using ATL, you can quickly develop efficient, concise code (effective and Slim codes) while providing maximum code generation and visual support for the development of COM components. Starting with Microsoft Visual C + + version 5.0, Microsoft integrates ATL into the Visual C + + development environment. Currently, ATL has become an important member of Microsoft's standard development tools and is increasingly valued by C + + developers.

Before ATL was produced, there were two main ways to develop COM components: one was to develop COM components directly using the COM SDK, and the other way was through COM support provided by MFC.

Developing COM components directly using the COM SDK is the most basic and flexible approach. However, this development method is very difficult and the workload is very large, on the one hand, requires developers to have a more in-depth understanding of the technical principles of COM, on the other hand, directly using the COM SDK requires developers to implement the COM application of every detail, complete a large number of repetitive work.

Using the COM support provided by MFC to develop COM applications can be said to be based on the use of COM SDK to improve the degree of automation and shorten the development time. MFC encapsulates the basic functionality of COM in a number of MFC C + + classes in an object-oriented manner, and developers get COM support by inheriting these classes. However, the COM components developed using MFC, especially the development of ActiveX controls, produce considerable code redundancy and must rely on the Run-time Library of MFC to run correctly.

ATL technology is a relatively ideal technology for developing COM components at the moment. The basic technologies used in ATL include COM technology, C + + template class technology (Template), and C + + multiple Inheritance technology (multi-inheritance).

2 Basic use of ATL

Developing a COM application using ATL can be basically divided into the following steps:

(1) Create a new ATL project and configure the project options appropriately.

(2) Add a new ATL class to the newly created project and perform some initial configuration work on the class.

(3) According to the basic requirements of COM applications, add new interface definitions to the new ATL classes and implement the corresponding interface member functions.

(4) Compile connection engineering, register COM application.

Using ATL technology to create ActiveX controls Circlectl

1) Create an ATL project

Use ATL COM AppWizard to create an ATL framework to name the project circle, follow the wizard prompts, and take the default setting, where the server type type is dynamic Link Library (DLL).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.