WTL简单问题
同桌老王 2005-03-03 02:44:08 用WTL向导生成一个SDI程序,改变其中的viewXXXX文件如下.
// WtlNewMenuView.h : interface of the CWtlNewMenuView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_WTLNEWMENUVIEW_H__C340430A_ABD4_44FE_8F31_C1B45BCA52B6__INCLUDED_)
#define AFX_WTLNEWMENUVIEW_H__C340430A_ABD4_44FE_8F31_C1B45BCA52B6__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
template <class T, COLORREF t_crBrushColor>
class CPaintBkgnd : public CMessageMap
{
public:
CPaintBkgnd() { m_hbrBkgnd = CreateSolidBrush(t_crBrushColor); }
~CPaintBkgnd() { DeleteObject ( m_hbrBkgnd ); }
BEGIN_MSG_MAP(CPaintBkgnd)
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
END_MSG_MAP()
LRESULT OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
T* pT = static_cast<T*>(this);
HDC dc = (HDC) wParam;
RECT rcClient;
pT->GetClientRect ( &rcClient );
FillRect ( dc, &rcClient, m_hbrBkgnd );
return 1; // we painted the background
}
protected:
HBRUSH m_hbrBkgnd;
};
class CWtlNewMenuView : public CWindowImpl<CWtlNewMenuView>,
public CPaintBkgnd<CWtlNewMenuView,RGB(200,0,0)>
{
public:
DECLARE_WND_CLASS(NULL)
BOOL PreTranslateMessage(MSG* pMsg);
typedef CPaintBkgnd<CWtlNewMenuView, RGB(0,0,255)> CPaintBkgndBase;
BEGIN_MSG_MAP(CWtlNewMenuView)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
CHAIN_MSG_MAP(CPaintBkgndBase)
END_MSG_MAP()
// Handler prototypes (uncomment arguments if needed):
// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_WTLNEWMENUVIEW_H__C340430A_ABD4_44FE_8F31_C1B45BCA52B6__INCLUDED_)
结果出现了三个相同的错误:
--------------------Configuration: WtlNewMenu - Win32 Debug--------------------
Compiling...
mainfrm.cpp
f:\临时目录\wtlnewmenu\wtlnewmenuview.h(48) : error C2352: 'CPaintBkgnd<class CWtlNewMenuView,16711680>::ProcessWindowMessage' : illegal call of non-static member function
f:\临时目录\wtlnewmenu\wtlnewmenuview.h(19) : see declaration of 'ProcessWindowMessage'
Generating Code...
Compiling...
WtlNewMenu.cpp
f:\临时目录\wtlnewmenu\wtlnewmenuview.h(48) : error C2352: 'CPaintBkgnd<class CWtlNewMenuView,16711680>::ProcessWindowMessage' : illegal call of non-static member function
f:\临时目录\wtlnewmenu\wtlnewmenuview.h(19) : see declaration of 'ProcessWindowMessage'
Generating Code...
Compiling...
WtlNewMenuview.cpp
f:\临时目录\wtlnewmenu\wtlnewmenuview.h(48) : error C2352: 'CPaintBkgnd<class CWtlNewMenuView,16711680>::ProcessWindowMessage' : illegal call of non-static member function
f:\临时目录\wtlnewmenu\wtlnewmenuview.h(19) : see declaration of 'ProcessWindowMessage'
Generating Code...
Error executing cl.exe.
WtlNewMenu.exe - 3 error(s), 0 warning(s)
为什么出现这个错误?