StatusHook.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #if 0
  2. #include <windows.h>
  3. #include "../Winamp/wa_ipc.h"
  4. #include "Main.h"
  5. #include <shlwapi.h>
  6. static WNDPROC waProc=0;
  7. static bool winampisUnicode=false;
  8. static LRESULT WINAPI StatusHookProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  9. {
  10. if (msg == WM_WA_IPC && lParam == IPC_HOOK_TITLESW)
  11. {
  12. LRESULT downTheLine = winampisUnicode?CallWindowProcW(waProc, hwnd, msg, wParam, lParam):CallWindowProcA(waProc, hwnd, msg, wParam, lParam);
  13. waHookTitleStructW *hook = (waHookTitleStructW *)wParam;
  14. if (!PathIsURLW(hook->filename) && winamp.GetStatusHook(hook->title, 2048, hook->filename))
  15. {
  16. return TRUE;
  17. }
  18. else
  19. return downTheLine;
  20. }
  21. if (waProc)
  22. {
  23. if (winampisUnicode)
  24. return CallWindowProcW(waProc, hwnd, msg, wParam, lParam);
  25. else
  26. return CallWindowProcA(waProc, hwnd, msg, wParam, lParam);
  27. }
  28. else
  29. return DefWindowProc(hwnd, msg, wParam, lParam);
  30. }
  31. void Hook(HWND winamp)
  32. {
  33. if (winamp)
  34. {
  35. winampisUnicode = !!IsWindowUnicode(winamp);
  36. if (winampisUnicode)
  37. waProc = (WNDPROC)SetWindowLongPtrW(winamp, GWLP_WNDPROC, (LONG_PTR)StatusHookProc);
  38. else
  39. waProc = (WNDPROC)SetWindowLongPtrA(winamp, GWLP_WNDPROC, (LONG_PTR)StatusHookProc);
  40. }
  41. }
  42. void Unhook(HWND winamp)
  43. {
  44. // if (winamp && GetWindowLongA(winamp,GWL_WNDPROC) == (LONG)StatusHookProc)
  45. //SetWindowLong(winamp, GWL_WNDPROC, (LONG)waProc);
  46. //waProc=0;
  47. }
  48. #endif