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)

为什么出现这个错误?
...全文
79 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
yinzhaohui 2005-03-03
  • 打赏
  • 举报
回复
class CWtlNewMenuView : public CWindowImpl<CWtlNewMenuView>,
public CPaintBkgnd<CWtlNewMenuView,RGB(200,0,0)>

typedef CPaintBkgnd<CWTLAppView,RGB(200,0,0)> CPaintBkgndBase;

要一样都是RGB(200,0,0)参数要一样

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧