Table of contents
1.
Introduction
2.
Adding Connecting points to an Object
3.
To add a connection point to a control or object.
4.
To reuse the connection point interface defined in another type of library.
5.
Frequently Asked Questions
5.1.
What is a template in OOP?
5.2.
What does DLL stand for?
5.3.
What are ATL applications?
5.4.
What are COM and ATL?
5.5.
What are C++ templates?
6.
Conclusion
Last Updated: Mar 27, 2024

How to add connection points to an object?

Author Muskan Sharma
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Hey Readers!!

Have you ever wondered about adding the connection points to an object in ATL?

In this article, you will learn about this in detail.

Let's begin!!

How to add connection points to an object?

Adding Connecting points to an Object

The ATL Tutorial walks through the process of developing a control that supports connection points, adds events, and implements the connection point. ATL uses the IConnectionPointImpl class to implement connection points.

You have two options for putting in a connecting point:

  • You can implement your outgoing event source by including a connection point to the control or object.
  • Use a connection point interface previously specified in a different library type.

To add a connection point to a control or object.

1. A dispinterface should be defined in the library block of the.idl file. The dispinterface will already be built if support for connection points was enabled when the control was created using the ATL Control Wizard. 

2. If connection point support was not enabled when the control was created, you would need to manually add the dispinterface to the.idl file. 

Here is an illustration of a dispinterface. While dispatch interfaces are unnecessary for outgoing interfaces, many scripting languages like VBScript and JScript do. Hence this example uses two of them:

3. In the project.idl file, add the dispinterface as the interface for the object. When you create the control, the ATI control wizard will create the default source entry if you enable the support for connecting points.

The following codes are to be used for manually adding this to the entry:


coclass Buddy
{
   [default] interface IBuddy;
   [default,source] dispinterface DBuddyEvents;
};

 

4. Class view will be used to add methods and properties to the event interface. It can be done by Right-clicking on class in the class view, going to ADD, and clicking Add Connecting Point.

5. Select the project's interfaces in the Implement Connection Point Wizard's Source Interfaces list box. If you select a control interface and click OK

To reuse the connection point interface defined in another type of library.

  1. Right-click a class in Class View that implements the BEGIN_COM_MAP macro, select Add from the shortcut menu, and then choose Add Connection Point.
  2. Click Add after selecting a type library and an interface in type library's Implement Connection Point Wizard.
  3. The object's dispinterface from the.idl file
  4. Use the importlib command on a library of that type.

Frequently Asked Questions

What is a template in OOP?

A template is a section of code that may be duplicated and altered to suit a particular situation.

What does DLL stand for?

When necessary, larger applications might load a collection of smaller programs known as a dynamic link library (DLL) to carry out specialized functions.

What are ATL applications?

ActiveX controls are frequently created using the Active Template Library (ATL), a wrapper library that makes COM development easier.

What are COM and ATL?

Microsoft created the Active Template Library (ATL), a collection of template-based C++ classes, to make designing Component Object Model (COM) objects easier.

What are C++ templates?

In C++, a template is a design pattern or recipe for developing a generic class or function.

Conclusion

This blog has extensively discussed adding connection points to an object. We hope this blog has helped you enhance your knowledge about adding a connection point to a control or object and reusing a connection point interface defined in another library type.


If you want to learn more deeply, check out the excellent content on the Coding Ninjas Website:

ATL connection point classesATL Copy Policy ClassesATL module classes

Refer to our guided paths on the Coding Ninjas Studio platform to learn more about DSA, DBMS, Competitive Programming, Python, Java, JavaScript, etc. 

Refer to the links problemstop 100 SQL problemsresources, and mock tests to enhance your knowledge.

For placement preparations, visit interview experiences and interview bundle.

Thank You

Do upvote our blog to help other ninjas grow. Happy Coding!

Live masterclass