Table of contents
1.
Introduction
2.
Component Object Model
3.
Controls in ATL
3.1.
CComControl Class
3.2.
IOleControlImpl Class
3.3.
IQuickActiveImpl Class
3.4.
IPointerInactiveImpl Class
3.5.
IOleObjectImpl Class
4.
Frequently Asked Questions
4.1.
What does ATL stand for?
4.2.
Why do we need ATL?
4.3.
What is the complete form of COM?
4.4.
Does COM structure the applications?
4.5.
COM works at what level?
5.
Conclusion
Last Updated: Mar 27, 2024
Hard

ATL Controls

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

Introduction

ATL stands for Active Template Library, developed by Microsoft. The purpose of ATL is to simplify the program based on the Component Object Model (COM ). An ATL contains a set of C++ template classes to develop efficient COM objects.

ATL Controls

In this blog, we will discuss the ATL controls: General Class support and various classes and methods available in ATL control to manipulate the COM. But before that, let's talk about COM.

Component Object Model

COM is an object-oriented system that creates software components at a binary level to interact with different applications. It is a distributed and platform-independent system that is a foundation for technologies like Microsoft OLEs, Activex, and others.

You should remember that COM is not an object-oriented language, nor is it structured as an application and programming language. COM is a standard to specify the object models and requirements to enable the COM objects to interact with other entities.

COM  is known as binary-specific components because the standard of COM is applied after the program is compiled into the machine code. In addition to defining the fundamental binary object standard, COM specifies a few virtual interfaces that offer features shared by all COM-based technologies and a select few functions that each component needs. In addition to defining how objects interact in a distributed environment, COM also includes security features that support system and component integrity.

There is a language requirement to implement the COM. A programming language must have the ability to create the structure of pointers either explicitly or implicitly and call functions with pointers.

Controls in ATL

In this section, we will discuss the general support classes in ATL, also known as the controls. Controls are available in various classes, but we will discuss the general support classes, mainly to know about the multiple classes and methods available to create COM.

CComControl Class

This class is responsible for creating and maintaining the ATL controls. CComControl class is considered a useful control helper function and a necessary data member for ATL controls.

To create a standard control, you need CComControl class because the ATL control wizard will derive our class from CComControl.

Syntax

template <class T, class WinBase = CWindowImpl<T>>
class ATL_NO_VTABLE CComControl: public CComControlBase,
    public WinBase;
You can also try this code with Online C++ Compiler
Run Code


Public Methods

Method Name

Description

CComControl::ControlQueryInterface Retrieves a pointer to the destined interface
CComControl::CreateControlWindow To create a window for controls
CComControl::FireOnChanged Notifies about the changed property to sink containers.
CComControl::FireOnRequestEdit Notifies about an upcoming change in property to sink containers.
CComControl::MessageBox To generate or display the message box.

IOleControlImpl Class

This class provides a default implementation of the interface known as IOleControl. It implements the IUnknown interface by sending the data or information to the inactive or dump device present in debug build.

Syntax

template<class T>
class IOleControlImpl
You can also try this code with Online C++ Compiler
Run Code


Public Methods

Method Name

Description

IOleControlImpl::FreezeEvents Signals whether the container accepts or ignores events from the control.
IOleControlImpl::GetControlInfo Provides information on the keyboard behavior of the control.
IOleControlImpl::OnAmbientPropertChange Notifies a control that one or more ambient characteristics of the container have changed.
IOleControlImpl::OnMenomic Notifies the control that a specific key was pushed.

IQuickActiveImpl Class

This class integrates the container's control initialization in one call to avoid delay during the initialization.

Syntax

template <class T>
class ATL_NO_VTABLE IQuickActivateImpl : public IQuickActivate
You can also try this code with Online C++ Compiler
Run Code


Public Methods

Method Name

Description

IQuickActiveImpl::GetContentExtent Obtains the size of the active control's display.
IQuickActiveImpl::QuickActivate To perform fast initialization of the loaded controls.
IQuickActiveImpl::SetContenExtent Shows information about the given display space of a container to control.

IPointerInactiveImpl Class

This class is responsible for manipulating the inactive objects in the program. An inactive refers to one that is running or loaded and cannot receive messages from the keyboard and mouse.

A small amount of mouse interaction can be supported by an inactive object, thanks to the IPointerInactive interface. For controls, this functionality is beneficial.

Syntax

template<class T>
class IPointerInactiveImpl
You can also try this code with Online C++ Compiler
Run Code


Public Methods

Method Name

Description

IPointerInactiveImpl::GetActivationPolicy Retrieves the object's current activation policy
IPointerInactiveImpl::OnInActiveMouseMove Informs the object that the mouse cursor has passed over it, proving that it is capable of firing mouse events.
IPointerInactiveImpl::OnInactiveSetCusor With this method, the inactive object is set as the mouse pointer.

IOleObjectImpl Class

The primary interface a container uses to communicate with control is the IOleObject interface.
Syntax

template<class T>
class ATL_NO_VTABLE IOleObjectImpl : public IOleObject
You can also try this code with Online C++ Compiler
Run Code


Public Methods

Method Name

Description

IOleObjectImpl::Advise Creates a link with the control that is advisory.
IOleObjectImpl::Close Change the state of control from running to loaded.
IOleObjectImpl::DoVerb Instructs the control to carry out one of its listed functions.
IOleObjectImpl::DoVerbDiscardUndo Instructs the control to remove any undo state it may be holding.
IOleObjectImpl::DoVerbHide Instructs the control to hide its user interface.
IOleObjectImpl::DoVerbInPlaceActivate Install the control's window and starts the control, but do not install the user interface.
IOleObjectImpl::DoVerbOpen Opens an editable version of the control in a different window.
IOleObjectImpl::DoVerbPrimary Whenever a user double-clicks a control, the desired action is carried out.
IOleObjectImpl::DoVerbShow Displays a recently added control to the user.
IOleObjectImpl::DoVerbUIactivate Shows the control's user interface, including menus and toolbars, and activates the control in place.

Frequently Asked Questions

What does ATL stand for?

ATL stands for the active template library.

Why do we need ATL?

We need ATL to provide efficient and easy-to-implement COM objects.

What is the complete form of COM?

COM stands for the Component Object Model.

Does COM structure the applications?

No COM provides standards to manipulate the COM objects.

COM works at what level?

COM standards implemented for the binary level.

Conclusion

This blog discusses the Active Template Library ATL and Component Object Model COM. We have also discussed the ATL Controls: General Support classes and various public methods available in ATL.

To learn more about ATL, check out the following articles.

 

To learn more about DSA, competitive coding, and many more knowledgeable topics, please look into the guided paths on Coding Ninjas Studio. Also, you can enroll in our courses and check out the mock test and problems available to you. Please check out our interview experiences and interview bundle for placement preparations.

Happy Coding!

Live masterclass