Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
ATL stands for Active Template Library. Its library contains numerous classes that can be used to manipulate and develop Windows. ATL contains a set of template-based C++ classes that help you create Component Object Model (COM) objects.
Based on the Standard Template Library (STL), the Active Template library extends the Visual Studio development environment with COM object automation wizards.
ATL can produce many objects, including dialogue boxes and Internet Explorer controls. ActiveX controls, dual interfaces, and connection points are all supported by ATL. By this, only we can understand how powerful ATL is.
So, Microsoft Active Template Library is a C++ template class specially made to make it easier to code and develop for the Component Object Model (COM) and ActiveX.
Working knowledge of COM is highly recommended to fully utilize ATL.
So, let us understand COM first:
Component Object Model
Computer frameworks are reusable templates that improve software programming reliability and productivity.
The component object model (COM) is a computer framework that integrates components with Microsoft® programming languages.
The component object model is a Microsoft® implementation of object-oriented programming (OOP) that allows developers to reuse COM components without knowing the underlying software language.
The component object model is a beautiful way to incorporate modular design into a software program.
What is a MODULAR DESIGN?
Modular design is an architectural approach based on creating small, simple software components. Each module is designed to serve a specific purpose and can operate independently of the application.
A printer connected to a computer that communicates via a printer driver is a good example of this technique in action.
Each COM framework component is an independent service that can be accessed by unrelated software programs. Programmers can thus reuse COM objects.
A variety of programming languages can be used to create COM objects. Object-oriented languages, such as C++, offer programming mechanisms that make it easier to implement COM objects. These objects can exist within the same process, in other processes, or even on remote computers.
This must have provided you with great insight into the Component Object Model.
ATL supports various COM features, including -
The presence of these features makes ATL highly recommended for creating software components. Several commonly used ATL Window classes useful in implementing dialog boxes are -
CDialogImpl - This class permits you to implement a modelled or modeless dialog box and process messages using a message map.
CAxDialogImpl - This class permits you to implement a modelled or modeless dialog box that hosts ActiveX controls.
CSimpleDialog - This class implements a dialog box with a few basic functionalities.
As the name suggests, we are going to study about CAxDialogImpl in this article:
So, let us start:
CAxDialogImpl
CAxDialogImpl implements a dialog box that hosts ActiveX Controls. This statement might trigger in the first go, but we will understand it in-depth in this section.
Dialog boxes are the pop-ups used to interact with the user. Dialog boxes also help in taking input from the user.
For example: When you leave the website or application, it asks you one more time whether you want to leave or not.
Now, there are two types of Dialog Boxes: Modal and Modeless.
Modal and Modeless Dialog Box
A modal dialog prevents you from accessing the rest of the application until it is closed. When a modal dialogue box is open, it is always active and prevents opening any other dialogue boxes or windows until it is closed.
While the modeless dialogue is open, you can use the rest of the application. Other application windows may hide it.
CAxDialoglmpl implements both types of DialogBox: Modal and Modeless.
Dialog Box hosts ActiveX controls. But what are ActiveX Controls? Let us explore:
ActiveX Controls
ActiveX is a set of tools created by Microsoft that allows Windows applications to have more functionality in networked environments. An ActiveX control is a program embedded in a Web site to improve the user's interaction with other applications running on the site. Customized applications for data collection, viewing specific types of files, and displaying animation. ActiveX controls are commonly used in command buttons, list boxes, and dialogue boxes.
Let us quickly see the Syntax of CAxDialoglmpl class:
Syntax
template <class T, class TBase = CWindow>
class ATL_NO_VTABLE CAxDialogImpl : public CDialogImplBaseT<TBase>
Parameters
T = It is your class that is derived from CAxDialogImpl.
TBase = It is the base class of your new class. Although, the default base class is CWindow.
Hierarchy
CAxDialogImpl is derived from CDialogImplBaseT, which is derived from TBase (CWindow by default) and CMessageMap.
An IDD member containing the dialogue template resource ID must be defined in your class. When you add an ATL Dialog object to your class using the Add Class dialogue box, the following line is automatically added:
enum { IDD = IDD_MYDLG };
Members
Member contains public and protected methods. Let us see them all:
Public Methods
Name
Description
CAxDialogImpl::AdviseSinkMap
Call this method to advise or unadvise all entries in the sink map event map of the object.
CAxDialogImpl::Create
To create a modeless dialog box, use this method.
CAxDialogImpl::DestroyWindow
To destroy a modeless dialog box, use this method.
CAxDialogImpl::DoModal
Use this method to create a modal dialog box.
CAxDialogImpl::EndDialog
Use this method to destroy a modal dialog box.
CAxDialogImpl::GetDialogProc
Use this method to get a pointer to the DialogProc callback function.
CAxDialogImpl::GetIDD
To collect the dialog template resource ID, use this method.
CAxDialogImpl::IsDialogMessage
Call this method to see if a message is intended for this dialogue box and, if so, to process it.
Protected Methods
Name
Description
CAxDialogImpl::m_bModal
It only exists in debug builds and is set to true if the dialogue box is modal.
Let us now discuss the syntax of each method and their return value:
1.CAxDialogImpl::AdviseSinkMap
Syntax
HRESULT AdviseSinkMap(bool bAdvise);
Parameters
Return Value
bAdvise: If all sink entries are to be advised, set this to true; otherwise, set this to false.
Return Value: If successful, the nRetCode parameter specified in the EndDialog call; otherwise, -1.
5. CAxDialogImpl::EndDialog
Syntax
BOOL EndDialog(int nRetCode);
Parameters
Return Value
nRetCode: The value to be returned by DoModal.
If the dialogue box is destroyed, TRUE; otherwise, FALSE.
6. CAxDialogImpl::GetDialogProc
Syntax
virtual DLGPROC GetDialogProc();
Return Value: This function returns a pointer to the DialogProc callback function.
7. CAxDialogImpl::GetIDD
Syntax
int GetIDD();
Return Value: The dialogue template resource ID is returned.
8. CAxDialogImpl::IsDialogMessage
Syntax
BOOL IsDialogMessage(LPMSG pMsg);
Parameters
Return Value
pMsg: A pointer to an MSG structure containing the message to be validated.
If the message has been processed, it returns TRUE; otherwise, it returns FALSE.
9. CAxDialogImpl::m_bModal
Syntax
bool m_bModal;
Frequently Asked Questions
What is ATL?
ATL stands for Active Template Library. Its library contains numerous classes that can be used to manipulate and develop Windows.
What are the ways to add a dialog box?
There are two ways to add a dialog box to the ATL project. These are - using ATL Dialog Wizard and manually adding it.
What are dialog boxes?
Dialog boxes are the pop-ups used to interact with the user. Dialog boxes also help in taking input from the user.
Which ATL libraries help in implementing dialog boxes?
Three ATL libraries help in dialog box implementation. These are - CDialogImpl, CAxDialogImpl, and CSimpleDialog.
Conclusion
In this article, we have discussed Windows support class-CAxDialogImpl in ATL. We have also discussed the types of Dialog Boxes: Modal and Modeless. At last, we have discussed the data members of CAxDialoglmpl class in ATL.
Do not stop learning! We recommend you read these articles -.