Welcome Ninjas. Have you heard of the Active Template Library? Are you curious to learn about it? Are you confused about the resources? Well, you are at the right place. In this blog, we will begin with the introduction of ATL and then look into the ATL COM property pages. Let us get started!
The active Template library is developed by Microsoft, and it comprises template-based C++ classes. ATL simplifies the programming of COM - The component Object Model. It can create dialog boxes, Internet explorer controls, etc. The Active Template Library, ATL makes programming Component Object Model (COM) objects easier. COM, being a binary specification, can be used to build and consume software components on Windows.
COM
COM refers to the Component Object Model. Component Object Model is a distributed, platform-independent and object-oriented system. Being the foundation technology forCOM is the foundation technology for Microsoft's OLE (compound documents) and ActiveX (Internet-enabled components) technologies, it is used for creating binary software components that can interact.
It is not difficult to create COM objects. They can be created using various languages. When created with object-oriented programming languages like C++, they even specify the implementation of COM objects.
ATL COM PROPERTY PAGES
Let's discuss what COM Property pages specify.
COM property pages give us a user interface for setting the properties of Component Object Models, COM objects. The property pages are COM objects that implement the IPropertyPage or IPropertyPage2 interface.
Note that we can build each Property page independently of the objects whose properties can be set. The property page just needs to provide a UI for calling methods on that interface.
Specifying Property Pages
In this blog section, We will look into how to specify the Property Pages. When you create an ActiveX control, it's preferred to correspond to the property pages used to set properties of your control.
Let us look at how to implement the ISpecifyPropertyPages using ATL:
Firstly, we need to derive the class from the ISpecifyPropertyPagesimpl
Next, add an entry for ISpecifyPropertyPages to the class's COM map.
Then, at last, We add the PROP_PAGE entry to the property map provided for each page.
The containers that display the property pages in the same order as the PROP_PAGE entries in the property map are preferred.
Let's have a look at the following code:
class ATL_NO_VTABLE CMyCtrl:
OtherInterfaces
public ISpecifyPropertyPagesImpl<CMyCtrl>
{
public:
BEGIN_COM_MAP(CMyCtrl)
OtherComMapEntries
COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
END_COM_MAP()
BEGIN_PROP_MAP(CMyCtrl)
//specify other entries of prop map
OtherPropMapEntries
PROP_PAGE(CLSID_PaintBrandPage)
PROP_PAGE(CLSID_PaintColorPage)
END_PROP_MAP()
You can also try this code with Online C++ Compiler
The property page container calls methods on the property page interface and tells the page to hide or show its user interface.
What is ATL Control Wizard?
ATL Control Wizard generates the necessary code for the steps following the addition of PROP_PAGE entries to the property map.
What does the class ISpecifyPropertyPagesSimpl do?
It implements the IUknown. It also provides us with a default implementation of ISpecifyPropertyPages interface.
Can a Host Window be reused?
A Host Window can be reused. But it's not recommended to do so.Usually, We associate a single control with a single host window and tie it for lifetime.
What is the window 'AtlAxWin100' used for?
It provides ATL's control-hosting functionality. Creating an instance of this class will automatically use the control-hosting API and create a host object associated with the window. Then it loads the host object with the control specified as the window's title.
Conclusion
Firstly, We hope the blog was easy to understand. This blog discussed the growing template library ATL, followed by the ATL COM property pages.
If you found this blog interesting and insightful, refer to similar blogs: