Delen via


CWindowImpl Class

This class provides methods for creating or subclassing a window.

template < 
   class T, 
   class TBase = CWindow, 
   class TWinTraits = CControlWinTraits  
> 
class ATL_NO_VTABLE CWindowImpl : 
   public CWindowImplBaseT< TBase, TWinTraits >

Parameters

  • T
    Your class, derived from CWindowImpl.

  • TBase
    The base class of your new class. The default base class is CWindow.

  • TWinTraits
    A traits class that defines styles for your window. The default is CControlWinTraits.

Remarks

CWindowImpl allows you to create a new window or subclass an existing window. CWindowImpl's window procedure uses a message map to direct messages to the appropriate handlers.

CWindowImpl::Create creates a new window based on the window class information managed by CWndClassInfo. CWindowImpl contains the DECLARE_WND_CLASS macro, which means CWndClassInfo will register a new window class. If you want to superclass an existing window class, derive your class from CWindowImpl and include the DECLARE_WND_SUPERCLASS macro. In this case, CWndClassInfo will register a window class that is based on an existing class but uses CWindowImpl::WindowProc. For example:

class ATL_NO_VTABLE CMyWindow :
   OtherInheritedClasses
   public CComControl<CMyWindow>
          // CComControl derives from CWindowImpl
{
public:
   // 1. The NULL parameter means ATL will generate a 
   //    name for the superclass 
   // 2. The "EDIT" parameter means the superclass is
   //    based on the standard Windows Edit box
   DECLARE_WND_SUPERCLASS(NULL, _T("EDIT"))

   // Remainder of class declaration omitted

Note

Because CWndClassInfo manages the information for a single window class, each window created through an instance of CWindowImpl will be based on the same window class.

CWindowImpl also supports window subclassing. The SubclassWindow method attaches an existing window to the CWindowImpl object and changes the window procedure to CWindowImpl::WindowProc. Each instance of CWindowImpl can subclass a different window.

Note

For any given CWindowImpl object, call either Create or SubclassWindow. You should not invoke both methods on the same object.

In addition to CWindowImpl, ATL provides CContainedWindow to create a window contained within another object.

The base class destructor (~CWindowImplRoot) ensures that the window is gone before the object is destroyed.

CWindowImpl derives from CWindowImplBaseT, which derives from CWindowImplRoot, which in turn derives from TBase and CMessageMap.

For more information about

See

Creating controls

ATL Tutorial

Using windows in ATL

ATL Window Classes

ATL Project Wizard

Creating an ATL Project

Windows

About Windows Procedures

Requirements

Header: atlwin.h

See Also

Reference

BEGIN_MSG_MAP

CComControl Class

Other Resources

CWindowImpl Members

ATL Class Overview