We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

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 >


Your class, derived from CWindowImpl.


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


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

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 :
   public CComControl<CMyWindow>
          // CComControl derives from CWindowImpl
   // 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

   // Remainder of class declaration omitted


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.


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


Creating controls

ATL Tutorial

Using windows in ATL

ATL Window Classes

ATL Project Wizard

Creating an ATL Project


About Windows Procedures

Header: atlwin.h