Table of contents
1.
Introduction
2.
CComCompositeControl Class
3.
Member Functions in CCOMCompositeControl Class 
4.
Frequently Asked Questions
4.1.
What is a class description of CComCompositeControl?
4.2.
What does Active Template Library mean?
4.3.
What are C+ templates?
4.4.
What are some ATL applications?
4.5.
What does Windows' COM object mean?
5.
Conclusion
Last Updated: Mar 27, 2024
Medium

Composite Controls Classes

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

Introduction

Microsoft Active Template Library is a C++ template class that is specially made to make it easier to code and develop for the Component Object Model (COM) and ActiveX. ATL provides service provider support and composite controls classes. In this blog, we will discuss the composite controls classes in detail. Let’s start going!

Composite Controls Classes

CComCompositeControl Class

CComCompositeControl ActiveX is derived from CComCompositeControl hosted by standard dialogue box controls. Due to their capacity to host additional controls, these are composite controls, and this class support composite controls.

This composite controls classes provides the methods needed to implement a composite control. The members of this class and this class cannot be used in Windows Runtime applications.

CComCompositeControl identifies the dialog resource to create the composite control by looking for an enumerated data member in the child class.

A control implemented by a class descended from CComCompositeControl has built-in default tab behavior. The control receives focus by tabbing to the control in a containing application. Subsequently, pressing the TAB key will cycle the focus through all of the contained controls in the composite control, then out of the composite control and onto the next item in the tab order of the container. The dialogue resource determines the tab order of the hosted controls, which controls the order in which tabs will be used.

Syntax of CCOMCompositeControl class is:-

template <class T>
class CComCompositeControl : public CComControl<T,CAxDialogImpl<T>>


In the above syntax, parameter p is your class, deriving from any additional interfaces you want to support for your composite control in addition to CComObjectRoot or CComObjectRootEx.

Member Functions in CCOMCompositeControl Class 

A class member function is a function that, like any other variable, has its definition or prototype within the class definition. It can access all class members for that object and can operate on any object.

Member functions in CCOMCompositeControl Class are defined below.

1. CComCompositeControl::AdviseSinkMap: The composite control's hosted controls can all be advised by calling this method.

Syntax of the above method is-

HRESULT AdviseSinkMap(bool bAdvise);


In the above syntax, parameter bAdvise, If all controls should be advised, then true; otherwise, false.

The method  CComCompositeControl::AdviseSinkMap return values:-

  • S_OK:-  Every control in the event sink map was successfully connected to or disconnected from its event source.
     
  • E_FAIL:- Not every control in the event sink map could be successfully connected to or disconnected from its event source.
     
  • E_POINTER:- This error typically denotes a problem with a template argument used in an IDispEventImpl or IDispEventSimpleImpl base class or a problem with an entry in the control's event sink map.
     
  • CONNECT_E_ADVISELIMIT:- The connection point can no longer accept any more connections because it has already reached its capacity.
     
  • CONNECT_E_CANNOTCONNECT:- The interface that this connection point requires is not supported by the sink.
     
  • CONNECT_E_NOCONNECTION:-  A valid connection is not represented by the cookie value. This error typically denotes a problem with a template argument used in an IDispEventImpl or IDispEventSimpleImpl base class or a problem with an entry in the control's event sink map.


2. CComCompositeControl::CalcExtent: This method is used to determine the dialogue resource's size in HIMETRIC units as the host for the composite control; call this method.

The syntax of the above method is-

BOOL CalcExtent(SIZE& size);


In the above syntax, parameter size is a pointer to a SIZE structure that this method should fill.

The method CComCompositeControl::CalcExtent returns the method's value as true If a dialogue box is hosting the control; otherwise false.

3. CComCompositeControl::Create: The control window for the composite control is created by calling this method.

The syntax of the above method is-

HWND Create(
    HWND hWndParent,
    RECT& /* rcPos */,
    LPARAM dwInitParam = NULL);


In the above syntax, the parameter hWndParent, is used to handle the parent window of the control, and rcPos is used for the reserved purpose.

The method CComCompositeControl::Create returns an access point for the recently made composite control dialogue box.

4. CComCompositeControl::CreateControlWindow: Call this method to create the control window and advise any hosted controls.

The syntax of the above method is-

virtual HWND CreateControlWindow(
    HWND hWndParent,
    RECT& rcPos);


In the above syntax, the parameter hWndParent,  is used to handle the parent window of the control, and rcPos is employed to manage the control's parent window.

5. CComCompositeControl::SetBackgroundColorFromAmbient:- This method uses the container's background color to set the composite control's background color.

The syntax of the above method is-

HRESULT SetBackgroundColorFromAmbient();


The above method returns an error HRESULT on failure and S_OK on success.

6. CComCompositeControl::m_hbrBackground: It is a data member which brushes the background. 

The syntax for the data member is:-

HBRUSH m_hbrBackground;


7. CComCompositeControl::m_hWndFocus: It is used to manage the handle of the window that currently has focus.

The syntax of the data member is:-

HWND m_hWndFocus;


8. CComCompositeControl::CComCompositeControl: It is a constructor which is used in composite controls classes. 

The syntax of the constructor is:-

CComCompositeControl();


9. CComCompositeControl::~CComCompositeControl: It is a destructor used in composite controls classes.

 The syntax for the destructor is:-

~CComCompositeControl();

Frequently Asked Questions

What is a class description of CComCompositeControl?

It creates ActiveX control classes based on dialogue resources by serving as their base class. These controls may include additional ActiveX controls.

What does Active Template Library mean?

The Active Template Library is a collection of Microsoft C++ template classes (program routines) that are specially made to make it easier to code and develop for the Component Object Model (COM) and ActiveX.

What are C+ templates?

In C++, templates are an effective tool for passing data types as parameters to generalized functions.

What are some ATL applications?

The Active Template Library (ATL), a wrapper library that facilitates COM development, is frequently used to create ActiveX controls. Applications written in MFC or ATL can be made using Visual Studio Community Edition or higher.

What does Windows' COM object mean?

The Microsoft Component Object Model is a distributed, object-oriented method for creating binary software components that can communicate (COM).

Conclusion

Congratulations on finishing the blog! We have discussed the composite controls classes in the active template library. Further, we have discussed various member functions in composite controls classes.

This blog has helped to enhance your knowledge of the composite controls classes in the active template library. Do not stop learning! We recommend you read some of our articles on the Active template library: 

1. Service provider support classes

2. Object safety classes

3. Running Object classes

Refers to our Guided Path to upskill yourself in DSA, Software Engineering, Competitive Programming, JavaScript, System Design, and many more! If you want to test your competency in coding, check out the mock test series and participate in the contests hosted on Coding Ninjas Studio!

But you have just started your learning process and are looking for questions from tech giants like Amazon, Microsoft, Uber, etc. For placement preparations, you must look at the problems, interview experiences, and interview bundles.

We wish you Good Luck! 

Happy Learning!

Live masterclass