37 lines
1.0 KiB
C++
37 lines
1.0 KiB
C++
#ifndef ZZG_CXMLTREESUBCLASSWND_2009_01_05
|
|
#define ZZG_CXMLTREESUBCLASSWND_2009_01_05
|
|
|
|
#pragma once
|
|
//#include "afx.h"
|
|
|
|
class CXMLTreeSubclassWnd : public CObject
|
|
{
|
|
public:
|
|
CXMLTreeSubclassWnd();
|
|
~CXMLTreeSubclassWnd();
|
|
// Subclass a window. Hook(NULL) to unhook (automatic on WM_NCDESTROY)
|
|
BOOL HookWindow(HWND hwnd);
|
|
BOOL HookWindow(CWnd* pWnd) { return HookWindow(pWnd->GetSafeHwnd()); }
|
|
void Unhook() { HookWindow((HWND)NULL); }
|
|
BOOL IsHooked() { return m_hWnd!=NULL; }
|
|
|
|
friend LRESULT CALLBACK HookWndProc(HWND, UINT, WPARAM, LPARAM);
|
|
friend class CSubclassWndMap;
|
|
|
|
virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);
|
|
LRESULT Default(); // call this at the end of handler fns
|
|
|
|
#ifdef _DEBUG
|
|
virtual void AssertValid() const;
|
|
virtual void Dump(CDumpContext& dc) const;
|
|
#endif
|
|
|
|
protected:
|
|
HWND m_hWnd; // the window hooked
|
|
WNDPROC m_pOldWndProc; // ..and original window proc
|
|
CXMLTreeSubclassWnd* m_pNext; // next in chain of hooks for this window
|
|
|
|
DECLARE_DYNAMIC(CXMLTreeSubclassWnd);
|
|
};
|
|
|
|
#endif |