没答出的,这分就给up的了

解决方案 »

  1.   

    BEGIN_MSG_MAP(CSimpleGrid)
    CHAIN_MSG_MAP(CComControl<CSimpleGrid>)
    DEFAULT_REFLECTION_HANDLER()
    MESSAGE_HANDLER(WM_CREATE, OnCreate)
    MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
    MESSAGE_HANDLER(WM_SIZE, OnSize)
    MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
    END_MSG_MAP()
    // Handler prototypes:
    //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
    //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
    //
      

  2.   

    Yeah,just the Same with SDK except some Macro packing!
    BEGIN_MSG_MAP(CJProgressBarImpl)
    MESSAGE_HANDLER(WM_CREATE, OnCreate)
    CHAIN_MSG_MAP( COffscreenDraw< T > )
    END_MSG_MAP()   LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    {
          _Init();
      return 0;
    }
    Please see Michael Dunn's WTL programming introduction series!
      

  3.   

    1,控件都从CComControl派生,从下面可以看到CComControl出CComControl的基类是CWindowImpl.template < class T, class WinBase = CWindowImpl < T > >
    class ATL_NO_VTABLE CComControl : public CComControlBase,
    public WinBase;
    2,看看CWindowImpl:
    template< class T,
    class TBase = CWindow,
    class TWinTrait = CControlWinTraits >
    class ATL_NO_VTABLE CWindowImpl :
    public CWindowImplBaseT< TBase, TWinTraits > 3,class CMyWindow : ...
    {
    public:
       ...   BEGIN_MSG_MAP(CMyWindow)
          MESSAGE_HANDLER(WM_PAINT, OnPaint)
          MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
          CHAIN_MSG_MAP(CComControl)
       END_MSG_MAP()   LRESULT OnPaint(UINT uMsg, WPARAM wParam,
                       LPARAM lParam, BOOL& bHandled)
       { ... }   LRESULT OnSetFocus(UINT uMsg, WPARAM wParam,
                          LPARAM lParam, BOOL& bHandled)
       { ... }
    };When a CMyWindow object receives a WM_PAINT message, the message is directed to CMyWindow::OnPaint for the actual processing. If OnPaint indicates the message requires further processing, the message will then be directed to the default message map in CComControl .