1
0

SendTo.h 2.7 KB

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