#ifndef _COMMON_HOOKPROC_HPP_
#define _COMMON_HOOKPROC_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _COMMON_VECTORHANDLER_HPP_
#include <common/vhandler.hpp>
#endif
#ifndef _COMMON_CALLBACKDATAHOOK_HPP_
#include <common/cbdatahk.hpp>
#endif



class WinHookProc : public VectorHandler
{
public:
  enum HookType{HookBefore,HookAfter};
  WinHookProc(HookType hookType=HookBefore);
	virtual ~WinHookProc();
	BOOL hookWin(HWND hWnd);
	BOOL unhookWin(void);
	HookType hookType(void)const;
	void hookType(HookType hookType);
	BOOL isOkay(void)const;
protected:
  virtual DWORD winID(void)const;
	CallbackDataHook windowProcedure(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
	WNDPROC prevHook(void)const;
	void prevHook(WNDPROC prevHook);
	HWND windowHandle(void)const;
	void windowHandle(HWND windowHandle);
private:
	static LRESULT CALLBACK hookProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam);
  WNDPROC mPrevHook;
	HWND mhHookWnd;
	HookType mHookType;
};

inline
WinHookProc::HookType WinHookProc::hookType(void)const
{
  return mHookType;
}

inline
void WinHookProc::hookType(HookType hookType)
{
  mHookType=hookType;
}

inline
WNDPROC WinHookProc::prevHook(void)const
{
  return mPrevHook;
}

inline
void WinHookProc::prevHook(WNDPROC prevHook)
{
  mPrevHook=prevHook;
}

inline
HWND WinHookProc::windowHandle(void)const
{
  return mhHookWnd;
}

inline
void WinHookProc::windowHandle(HWND windowHandle)
{
  mhHookWnd=windowHandle;
}
#endif
