Re: template question.
"tather" <tather@gmail.com> wrote in message
news:1184723640.630539.211770@g12g2000prg.googlegroups.com...
I found these code in http://www.parkscomputing.com
but I can not compile it successful.
------------------------------------------------
typedef LONG (__stdcall * forwardFn_t)(HWND, UINT, WPARAM, LPARAM);
template<UINT msg> class Handler;
template<> class Handler<WM_PAINT>
{
protected:
virtual void OnPaint() = 0;
public:
LRESULT Handle(WPARAM wParam, LPARAM lParam)
{
OnPaint();
return 0L;
}
static void Forward(HWND hWnd, forwardFn_t pfn)
{
(*pfn)(hWnd, msg, 0L, 0L);
}
};
----------------------------------------------------
error C2065: 'msg' : undeclared identifier
Why the error occur, and How can I resolve it to get the same fuction?
It most likely means it doesn't know what UINT means, so msg is undeclared.
It's common for some compilers to give an error on the next line, or next
syntax word it finds.
I'm sure if you do:
typedef unsigned int UINT;
before that line it will get past that error, but then it'll probably bitch
about <WM_PAINT> etc... This is windows code and expects windows headers.
Try including <windows.h>