template <class T>
static void SubClassing(HWND hWnd){
T* pWnd = (T*)(CWnd*)CWnd::FromHandle(hWnd);
pWnd->hook_proc = (WNDPROC)SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)(WNDPROC)SubClassingProc<T>);
}
template <class T>
LRESULT SubClassingProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
T* pWnd = (T*)(CWnd*)CWnd::FromHandle(hWnd);
switch (message){
case WM_LBUTTONDOWN:{
pWnd->LButtonDown();
break;
}
case WM_LBUTTONUP:{
pWnd->LButtonUp();
break;
}
default:
break;
}
return CallWindowProc(pWnd->hook_proc, hWnd, message, wParam, lParam);
}