pe_subclass.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "main.h"
  2. static HMENU last_playlistscmdmenu = NULL;
  3. static WNDPROC PE_oldWndProc;
  4. static WORD waCmdMenuID;
  5. static BOOL CALLBACK PE_newWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  6. {
  7. if (uMsg == WM_COMMAND && wParam > 45000 && wParam < 55000)
  8. {
  9. if (LoadPlaylist(wParam - 45000))
  10. return 0;
  11. }
  12. else if (uMsg == WM_INITMENUPOPUP)
  13. {
  14. HMENU hmenuPopup = (HMENU) wParam;
  15. if (hmenuPopup == wa_playlists_cmdmenu)
  16. {
  17. if (!waCmdMenuID)
  18. {
  19. waCmdMenuID = (WORD)SendMessage(plugin.hwndWinampParent,WM_WA_IPC,0,IPC_REGISTER_LOWORD_COMMAND);
  20. }
  21. if (last_playlistscmdmenu)
  22. {
  23. RemoveMenu(wa_playlists_cmdmenu, waCmdMenuID, MF_BYCOMMAND);
  24. DestroyMenu(last_playlistscmdmenu);
  25. last_playlistscmdmenu = NULL;
  26. }
  27. mlGetTreeStruct mgts = { 3001, 45000, -1};
  28. last_playlistscmdmenu = (HMENU)SendMessage(plugin.hwndLibraryParent, WM_ML_IPC, (WPARAM) &mgts, ML_IPC_GETTREE);
  29. if (last_playlistscmdmenu)
  30. {
  31. MENUITEMINFOW menuItem = {sizeof(MENUITEMINFOW), MIIM_SUBMENU | MIIM_ID | MIIM_TYPE, MFT_STRING,
  32. MFS_ENABLED, waCmdMenuID, last_playlistscmdmenu, NULL, NULL, NULL,
  33. WASABI_API_LNGSTRINGW(IDS_OPEN_PLAYLIST_FROM_ML), 0};
  34. // if there's no playlists then let the user know this
  35. if(!AGAVE_API_PLAYLISTS->GetCount())
  36. {
  37. wchar_t buf[64] = {0};
  38. DestroyMenu(last_playlistscmdmenu);
  39. menuItem.hSubMenu = last_playlistscmdmenu = CreateMenu();
  40. InsertMenuW(menuItem.hSubMenu, 0, MF_BYPOSITION | MF_STRING | MF_GRAYED, 0, WASABI_API_LNGSTRINGW_BUF(IDS_NO_PLAYLIST_IN_LIBRARY,buf,64));
  41. }
  42. InsertMenuItemW(wa_playlists_cmdmenu, 1, TRUE, &menuItem);
  43. }
  44. }
  45. }
  46. return CallWindowProc(PE_oldWndProc, hwndDlg, uMsg, wParam, lParam);
  47. }
  48. static HWND hwnd_pe = NULL;
  49. void HookPlaylistEditor()
  50. {
  51. hwnd_pe =(HWND)SendMessage(plugin.hwndWinampParent,WM_WA_IPC,IPC_GETWND_PE,IPC_GETWND);
  52. if (hwnd_pe)
  53. PE_oldWndProc=(WNDPROC) SetWindowLongPtr(hwnd_pe,GWLP_WNDPROC,(LONG_PTR)PE_newWndProc);
  54. }
  55. void UnhookPlaylistEditor()
  56. {
  57. SetWindowLongPtr(hwnd_pe,GWLP_WNDPROC,(LONG_PTR)PE_oldWndProc);
  58. }