使用中包含的Windows

ATL实现包含了 CContainedWindowT的窗口。 一个包含窗口表示将其消息发送到容器对象而不是处理它们在其自己的选件类的窗口。

备注

不必从 CContainedWindowT 派生选件类才能使用包含窗口。

包含窗口,可以创建超类时现有Windows选件类或子类现有的窗口。 会创建现有Windows选件类,构造函数首先指定现有类名。CContainedWindowT 对象的窗口。 然后调用 CContainedWindowT::Create。 对子类现有的窗口,无需指定Windows类名(向构造函数传递 NULL )。 调用与处理的 CContainedWindowT::SubclassWindow 方法到子类的窗口。

在容器的数据成员类别,通常使用包含窗口。 容器不必是windows;但是,它必须从 CMessageMap派生。

一个包含窗口可以使用替换消息映射来处理其消息。 如果您有多个包含窗口,应声明了替换消息映射,其中每个计数器都有单独包含窗口相对应。

示例

以下容器选件类的示例使用两个包含窗口的:

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()

};

有关包含窗口的更多信息,请参见 SUBEDIT 示例。

请参见

其他资源

ATL窗口选件类