winampHook.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef NULLSOFT_WINAMP_HOOK_HEADER
  2. #define NULLSOFT_WINAMP_HOOK_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <wtypes.h>
  7. #include <map>
  8. class ifc_winamphook;
  9. class WinampHook
  10. {
  11. protected:
  12. WinampHook(HWND hwndWinamp);
  13. ~WinampHook();
  14. public:
  15. static HRESULT CreateInstance(HWND hwndWinamp, WinampHook **instance);
  16. public:
  17. ULONG AddRef();
  18. ULONG Release();
  19. HRESULT RegisterCallback(ifc_winamphook *callback, UINT *cookie);
  20. HRESULT UnregisterCallback(UINT cookie);
  21. HWND GetWinamp();
  22. LRESULT CallPrevWinampProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
  23. LRESULT CallDefWinampProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
  24. protected:
  25. HRESULT AttachToWinamp();
  26. HRESULT DetachFromWinamp();
  27. LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
  28. LRESULT OnWinampDestroy();
  29. LRESULT OnWinampIPC(UINT commandId, WPARAM param);
  30. void OnWinampCommand(UINT commandId, UINT controlId, HWND hControl);
  31. void OnSysColorChange();
  32. protected:
  33. typedef enum
  34. {
  35. flagUnicode = 0x00000001,
  36. } Flags;
  37. typedef std::map<UINT, ifc_winamphook*> CallbackMap;
  38. friend static LRESULT CALLBACK WinampWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  39. protected:
  40. ULONG ref;
  41. HWND hwnd;
  42. WNDPROC originalProc;
  43. UINT flags;
  44. UINT lastCookie;
  45. CallbackMap callbackMap;
  46. };
  47. #endif //NULLSOFT_WINAMP_HOOK_HEADER