Table of contents
1.
Introduction
2.
About ATL
3.
Site Information Classes
4.
IObjectWithSiteImpl
4.1.
Control in ATL
4.2.
Syntax
4.3.
Members
5.
IOleObjectImpl
5.1.
Syntax
5.2.
Members
6.
Frequently Asked Questions
6.1.
What are the applications of ATL?
6.2.
What is an MFC application?
6.3.
What is a DTO class?
6.4.
What is a class data value?
6.5.
What are classes in ATL?
7.
Conclusion
Last Updated: Mar 27, 2024
Medium

Site Information Classes

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

Introduction

Hello Ninja,
Software development is so vast that it has been divided into various subcategories for better execution and division of tasks for development. This includes architecture development of software. Microsoft, one of the leading software companies, works to ease our workload. Thus, site information classes were developed.

Site Information Classes

This article will teach you all you need to know to start working with site information classes. These are a part of ATL which is Microsoft’s active template library, that helps in software architecture development.

About ATL

Microsoft's Active Template Library has numerous classes that permit you to use, manipulate and implement Windows. It provides an impressive implementation that would not cause overhead on your code.
It is suggested to have good knowledge about COM before getting started with ATL.

COM or component object model is an architectural base using which we build software services. Consider it a pillar that provides support to the ceilings of software development. 

COM or component object model

COM is an older version of the .NET framework. It is still widely used. A distributed, object-oriented approach for developing binary software components that may communicate is known as the Microsoft Component Object Model (COM).

The ATL is used to reuse existing designs of the COM. It works on source composition that is, it detects the source code to determine components. It can be converted into binary composition after software development. 
Thus these classes help you to build a software architecture more easily.
There are a lot of template classes inside the active template library. We will discuss the site information classes.

Site Information Classes

Classes in ATL are classified into various classes, data types, modules, controls, etc. Site information classes are among these classifications. 
Site information classes are classes that help to communicate with the object's site.
These classes are further classified into two.

  • IObjectWithSiteImpl
     
  • IOleObjectImpl
     

We will learn about the subdivision of the site information classes in detail in the next sections.

IObjectWithSiteImpl

The objective of site information classes to communicate with the object site is fulfilled by the IObjectWithSiteImpl class. This method is similar to IObjectWithSite. The only difference is that IObjectWithSiteImpl is used for objects that are not a control.

Control in ATL

The general support classes in ATL are also known as the controls. Controls are available in various classes. They help to implement the ATL library classes, such as site information classes.  
Whereas IObjectWithSite is used for objects that are a control.

While using site information classes, we always inherit IObjectWithSite first, then IObjectWithSiteImpl.
It consists of members who are passed along with IObjectWithSiteImpl to access the site of objects.
It mainly requires two methods to function:

  • GetSite - to receive a site address to access in the form of a pointer.
     
  • SetSite - to set an IUnknown pointer for the site’s address. 
     

NOTE: IUnknown is an interface that helps to get the pointer for the object location and access objects in ATL.

Syntax

The syntax to use site information classes as IObjectWithSiteImpl is

template <class name>
    class ATL_NO_VTABLE IObjectWithSiteImpl:
    public IObjectWithSite


Breaking down the syntax:

  • Declare the template library with the custom class name.
     
  • Declare class with ATL class name and IObjectWithSiteImpl.
     
  • Declare IObjectWithSiteImpl as a public function inside the class.

Members

The IObjectWithSiteImpl class under site information classes can be used differently. A few global functions are added using the scope resolution operator (::). These functions act like members of the site information class. There are a total of four members, among which three are public methods and one is a public data member.

IObjectWithSiteImpl

These members perform different functions to access the object's site.
The table below shows all the members, their functions, and the query to use.

Table

IOleObjectImpl

The objective of site information classes to communicate with the object using its location/site is fulfilled by the IOleObjectImpl class. This method is similar to the method discussed above. The only difference between IOleObjectImpl and IObjectWithSiteImpl is that the former gives access to objects that are an ATL control. Whereas, the latter gives access to objects that are not an ATL control.

IOleObjectImpl consists of members that are used with IOleObjectImpl class to execute tasks with ease. These are passed along with IOleObjectImpl to access the object using the object’s location.

Controls in ATL are the support classes used to execute COM easily.
NOTE: This cannot be used for applications executed in the window’s runtime. 

Syntax

The syntax to use site information classes as IOleObjectImpl is

template<class name>
class ATL_NO_VTABLE IOleObjectImpl : 
public IOleObject


Breaking down the syntax:

  • Declare the template library with the custom class name.
     
  • Declare class with ATL class name and IOleObjectImpl.
     
  • Declare IOleObject as a public function inside the class.

Members

The IOleObjectImpl class under site information classes can be used differently. A few global functions are added using the scope resolution operator (::). These functions act like members of the class. These members help to access site information using the control classes.
There are a total of 40 members of the IOleObjectImpl class. All of these are public methods.
The table below shows a few crucial members, their functions, and the query to be used.

Members Table 

Frequently Asked Questions

What are the applications of ATL?

ActiveX controls are frequently created using the Active Template Library (ATL), a wrapper library that makes COM development easier. MFC(Microsoft Foundation Class) or ATL(Active Template Library) applications may be produced with Visual Studio Community Edition or higher.

What is an MFC application?

Based on the Microsoft Foundation Class (MFC) Library, an MFC application is a Windows executable program.

What is a DTO class?

Data Transfer Objects are public classes with no methods other than the compiler-supplied default constructor, having only public (static) fields limited to easily serializable types.

What is a class data value?

Information that is shared by all the instances or aggregate information about the instances is kept in a class data value.

What are classes in ATL?

Classes in ATL contain data necessary to display to various destinations, like a printer, metafile, or ActiveX control. Classes instance data in the ATL windowing code.

Conclusion

We have discussed all the necessary information you need to start working with site information classes in ATL. We have discussed the subdivisions under site information classes in detail, along with various members of the subdivisions.

Refer to the below topics for more understanding of ATL classes:

If you want to learn and upskill yourself, the Coding Ninja has got you covered. You can refer to the open-source guide and learn about Data Structures and AlgorithmsCompetitive ProgrammingJavaScriptSystem Design, and many more! 

Refer to our guided paths on Coding Ninjas Studioresources on Coding Ninjas Studio, and Coding Ninjas Studio Library to learn about many more amazing topics. Also, refer to the mock test and problems available to better grasp concepts. Have a look at the interview experiences and interview bundle for placement preparations.

Happy Learning!

Live masterclass