Using Contained Windows
ATL implements contained windows with CContainedWindowT. A contained window represents a window that delegates its messages to a container object instead of handling them in its own class.
Observação
You do not need to derive a class from CContainedWindowT in order to use contained windows.
With contained windows, you can either superclass an existing Windows class or subclass an existing window. To create a window that superclasses an existing Windows class, first specify the existing class name in the constructor for the CContainedWindowT object. Then call CContainedWindowT::Create. To subclass an existing window, you don't need to specify a Windows class name (pass NULL to the constructor). Simply call the CContainedWindowT::SubclassWindow method with the handle to the window being subclassed.
You typically use contained windows as data members of a container class. The container does not need to be a window; however, it must derive from CMessageMap.
A contained window can use alternate message maps to handle its messages. If you have more than one contained window, you should declare several alternate message maps, each corresponding to a separate contained window.
Example
Following is an example of a container class with two contained windows:
class CMyContainer : public CMessageMap
{
public:
CContainedWindow m_wndEdit;
CContainedWindow m_wndList;
CMyContainer() : m_wndEdit(_T("Edit"), this, 1),
m_wndList(_T("List"), this, 2)
{
}
BEGIN_MSG_MAP(CMyContainer)
ALT_MSG_MAP(1)
// handlers for the Edit window go here
ALT_MSG_MAP(2)
// handlers for the List window go here
END_MSG_MAP()
};
For more information about contained windows, see the SUBEDIT sample.