Undocumented Corner
by George Shepherd and Scot Wingo



Example 1: 
template <class T>
class ATL_NO_VTABLE CComControl : public CComControlBase, 
                                  public CWindowImpl<T>
{
 ...
};


Listing One
class ATL_NO_VTABLE CATLCtl : 
   public CComObjectRootEx<CComSingleThreadModel>,
   public CComCoClass<CATLCtl, &CLSID_ATLCtl>,
   public CComControl<CATLCtl>,
   public IDispatchImpl<IATLCtl, &IID_IATLCtl, &LIBID_ATLCTLSVRLib>,
   public IProvideClassInfo2Impl<&CLSID_ATLCtl, NULL, &LIBID_ATLCTLSVRLib>,
   public IPersistStreamInitImpl<CATLCtl>,
   public IPersistStorageImpl<CATLCtl>,
   public IQuickActivateImpl<CATLCtl>,
   public IOleControlImpl<CATLCtl>,
   public IOleObjectImpl<CATLCtl>,
   public IOleInPlaceActiveObjectImpl<CATLCtl>,
   public IViewObjectExImpl<CATLCtl>,
   public IOleInPlaceObjectWindowlessImpl<CATLCtl>,
   public IDataObjectImpl<CATLCtl>,
   public ISpecifyPropertyPagesImpl<CATLCtl>
{
 ... 
};

Listing Two
class CWndClassInfo {
public:
   WNDCLASSEX m_wc;
   LPCTSTR m_lpszOrigName;
   WNDPROC pWndProc;
   LPCTSTR m_lpszCursorID;   
   BOOL m_bSystemCursor;
   ATOM m_atom;
   TCHAR m_szAutoName[13];
   ATOM Register(WNDPROC*);
};

Listing Three
#define DECLARE_WND_CLASS(WndClassName) \
static CWndClassInfo& GetWndClassInfo() \
{ \
   static CWndClassInfo wc = \
   { \
      { sizeof(WNDCLASSEX), CS_HREDRAW|CS_VREDRAW, StartWindowProc, \
        0, 0, 0, 0, 0, (HBRUSH)(COLOR_WINDOW+1), 0, WndClassName, 0 }, \
        NULL, NULL, IDC_ARROW, TRUE, 0, _T("") \
   }; \
   return wc; \
}

Listing Four
BEGIN_MSG_MAP(CATLCtl)
   MESSAGE_HANDLER(WM_PAINT, OnPaint)
   MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
   MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
END_MSG_MAP()


2


