SendTo.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef NULLSOFT_SEND_TO_HELPER_CLASS_H
  2. #define NULLSOFT_SEND_TO_HELPER_CLASS_H
  3. #include "../../General/gen_ml/ml_ipc.h"
  4. #include "main.h"
  5. #include <strsafe.h>
  6. class SendToMenu
  7. {
  8. public:
  9. SendToMenu()
  10. {
  11. memset(&sendTo, 0, sizeof(sendTo));
  12. }
  13. void AddHere(HWND hwnd, HMENU hMenu, int type, int simple = 0, int trueSourceType = 0)
  14. {
  15. sendTo.mode = 0;
  16. sendTo.hwnd = 0;
  17. sendTo.build_hMenu = 0;
  18. IPC_LIBRARY_SENDTOMENU = SendMessage(plugin.hwndWinampParent, WM_WA_IPC, (WPARAM)&"LibrarySendToMenu", IPC_REGISTER_WINAMP_IPCMESSAGE);
  19. if (IPC_LIBRARY_SENDTOMENU > 65536 && SendMessage(plugin.hwndWinampParent, WM_WA_IPC, (WPARAM)0, IPC_LIBRARY_SENDTOMENU) == (LRESULT)-1)
  20. {
  21. sendTo.mode = 1;
  22. sendTo.hwnd = hwnd;
  23. sendTo.data_type = type; //ML_TYPE_ITEMRECORDLIST;
  24. sendTo.ctx[1] = simple;
  25. sendTo.ctx[2] = trueSourceType;
  26. sendTo.build_hMenu = hMenu;
  27. }
  28. }
  29. bool WasClicked(int popUpReturnVal)
  30. {
  31. if (sendTo.mode == 2)
  32. {
  33. sendTo.menu_id = popUpReturnVal;
  34. if (SendMessage(plugin.hwndWinampParent, WM_WA_IPC, (WPARAM)&sendTo, IPC_LIBRARY_SENDTOMENU) == (LRESULT)-1)
  35. return true;
  36. }
  37. return false;
  38. }
  39. void Cleanup()
  40. {
  41. if (sendTo.mode)
  42. {
  43. sendTo.mode = 4;
  44. SendMessage(plugin.hwndWinampParent, WM_WA_IPC, (WPARAM)&sendTo, IPC_LIBRARY_SENDTOMENU); // cleanup
  45. }
  46. sendTo.build_hMenu = 0;
  47. }
  48. bool InitPopupMenu(WPARAM wParam)
  49. {
  50. if (wParam && (HMENU)wParam == sendTo.build_hMenu && sendTo.mode == 1)
  51. {
  52. if (SendMessage(plugin.hwndWinampParent, WM_WA_IPC, (WPARAM)&sendTo, IPC_LIBRARY_SENDTOMENU) == (LRESULT)-1)
  53. sendTo.mode = 2;
  54. return true;
  55. }
  56. return false;
  57. }
  58. // still need to free it on your own
  59. void SendItemRecordList(itemRecordList *obj)
  60. {
  61. sendTo.data_type = ML_TYPE_ITEMRECORDLIST;
  62. sendTo.mode = 3;
  63. sendTo.data = (void*) & obj;
  64. SendMessage(plugin.hwndWinampParent, WM_WA_IPC, (WPARAM)&sendTo, IPC_LIBRARY_SENDTOMENU);
  65. }
  66. void SendFilenames(const wchar_t *filenames)
  67. {
  68. sendTo.data_type = ML_TYPE_FILENAMESW;
  69. sendTo.mode = 3;
  70. sendTo.data = (void*)filenames;
  71. SendMessage(plugin.hwndWinampParent, WM_WA_IPC, (WPARAM)&sendTo, IPC_LIBRARY_SENDTOMENU);
  72. }
  73. LRESULT SendPlaylist(mlPlaylist *playlist)
  74. {
  75. sendTo.data_type = ML_TYPE_PLAYLIST;
  76. sendTo.mode = 3;
  77. sendTo.data = (void*)playlist;
  78. return SendMessage(plugin.hwndWinampParent, WM_WA_IPC, (WPARAM)&sendTo, IPC_LIBRARY_SENDTOMENU);
  79. }
  80. LRESULT SendPlaylists(mlPlaylist **playlists)
  81. {
  82. sendTo.data_type = ML_TYPE_PLAYLISTS;
  83. sendTo.mode = 3;
  84. sendTo.data = (void*)playlists;
  85. return SendMessage(plugin.hwndWinampParent, WM_WA_IPC, (WPARAM)&sendTo, IPC_LIBRARY_SENDTOMENU);
  86. }
  87. private:
  88. librarySendToMenuStruct sendTo;
  89. };
  90. #endif