pe_subclass.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include "main.h"
  2. #include "api__ml_local.h"
  3. #include "resource.h"
  4. static WNDPROC PE_oldWndProc;
  5. static HMENU last_viewmenu = NULL;
  6. static WORD waCmdMenuID;
  7. static INT_PTR CALLBACK PE_newWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  8. {
  9. if (uMsg == WM_COMMAND && wParam > 45000 && wParam < 57000)
  10. {
  11. int n = wParam - 45000;
  12. if (m_query_list[n])
  13. {
  14. queryItem *item = m_query_list[n];
  15. wchar_t configDir[MAX_PATH] = {0};
  16. PathCombineW(configDir, g_viewsDir, item->metafn);
  17. C_Config viewconf(configDir);
  18. main_playQuery(&viewconf, item->query, 0, 0);
  19. return 0;
  20. }
  21. }
  22. else if (uMsg == WM_INITMENUPOPUP)
  23. {
  24. HMENU hmenuPopup = (HMENU) wParam;
  25. if (hmenuPopup == wa_playlists_cmdmenu)
  26. {
  27. if (!waCmdMenuID)
  28. {
  29. waCmdMenuID = (WORD)SendMessage(plugin.hwndWinampParent,WM_WA_IPC,0,IPC_REGISTER_LOWORD_COMMAND);
  30. }
  31. if (last_viewmenu)
  32. {
  33. RemoveMenu(wa_playlists_cmdmenu, waCmdMenuID, MF_BYCOMMAND);
  34. DestroyMenu(last_viewmenu);
  35. last_viewmenu = NULL;
  36. }
  37. mlGetTreeStruct mgts = { 1000, 45000, -1};
  38. last_viewmenu = (HMENU)SendMessage(plugin.hwndLibraryParent, WM_ML_IPC, (WPARAM) & mgts, ML_IPC_GETTREE);
  39. if (last_viewmenu)
  40. {
  41. MENUITEMINFOW menuItem = {sizeof(MENUITEMINFOW), MIIM_SUBMENU | MIIM_ID | MIIM_TYPE, MFT_STRING,
  42. MFS_ENABLED, waCmdMenuID, last_viewmenu, NULL, NULL, NULL,
  43. WASABI_API_LNGSTRINGW(IDS_OPEN_MEDIA_LIBRARY_VIEW_RESULTS), 0};
  44. if (GetMenuItemCount(last_viewmenu) > 0)
  45. {
  46. InsertMenuItemW(wa_playlists_cmdmenu, 1, TRUE, &menuItem);
  47. }
  48. else
  49. {
  50. DestroyMenu(last_viewmenu);
  51. last_viewmenu=0;
  52. }
  53. }
  54. }
  55. }
  56. return CallWindowProc(PE_oldWndProc, hwndDlg, uMsg, wParam, lParam);
  57. }
  58. static HWND hwnd_pe = NULL;
  59. void HookPlaylistEditor()
  60. {
  61. hwnd_pe = (HWND)SendMessage(plugin.hwndWinampParent, WM_WA_IPC, IPC_GETWND_PE, IPC_GETWND);
  62. if (IsWindow(hwnd_pe))
  63. PE_oldWndProc = (WNDPROC) SetWindowLongPtrW(hwnd_pe, GWLP_WNDPROC, (LONG_PTR)PE_newWndProc);
  64. }
  65. void UnhookPlaylistEditor()
  66. {
  67. SetWindowLongPtrW(hwnd_pe, GWLP_WNDPROC, (LONG_PTR)PE_oldWndProc);
  68. }