ml_ipc.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef _WA_ML_IPC_H_
  2. #define _WA_ML_IPC_H_
  3. #include <windows.h>
  4. #include <stddef.h>
  5. //# IPC_LIBRARY_SENDTOMENU
  6. /*
  7. Basically for the sendto menu, do this:
  8. librarySendToMenuStruct s={0,};
  9. int IPC_LIBRARY_SENDTOMENU=SendMessage(hMainWindow,WM_WA_IPC,(WPARAM)&"LibrarySendToMenu",IPC_REGISTER_WINAMP_IPCMESSAGE);
  10. if (IPC_LIBRARY_SENDTOMENU > 65536 && SendMessage(hMainWindow,WM_WA_IPC,(WPARAM)0,IPC_LIBRARY_SENDTOMENU)==0xffffffff)
  11. {
  12. s.mode=1;
  13. s.hwnd=myWnd;
  14. s.data_type=mydatatype;
  15. s.build_hMenu=mysubmenu;
  16. }
  17. TrackPopupMenu();
  18. if (ret)
  19. {
  20. if (unrecognized ret)
  21. {
  22. if (s.mode == 2)
  23. {
  24. s.menu_id=ret;
  25. if (SendMessage(hMainWindow,WM_WA_IPC,(WPARAM)&s,IPC_LIBRARY_SENDTOMENU)==0xffffffff)
  26. {
  27. // build my data.
  28. s.mode=3;
  29. s.data=my data;
  30. SendMessage(hMainWindow,WM_WA_IPC,(WPARAM)&s,IPC_LIBRARY_SENDTOMENU)
  31. // free my data
  32. }
  33. }
  34. }
  35. }
  36. if (s.mode)
  37. {
  38. s.mode=4;
  39. SendMessage(hMainWindow,WM_WA_IPC,(WPARAM)&s,IPC_LIBRARY_SENDTOMENU) // cleanup
  40. }
  41. ...
  42. WM_INITMENUPOPUP:
  43. if (wParam && (HMENU)wParam == s.build_hMenu && s.mode==1)
  44. {
  45. if (SendMessage(hMainWindow,WM_WA_IPC,(WPARAM)&s,IPC_LIBRARY_SENDTOMENU)==0xffffffff)
  46. s.mode=2;
  47. }
  48. kinda complex and gross, yes?
  49. */
  50. typedef struct { // always init this to all 0s
  51. int mode; // mode can be 0, to see if sendto is available. If sendto is available, we'll return 0xffffffff.
  52. // mode = 1 means we are building the menu. data_type should be set. on success, this will return 0xffffffff.
  53. // mode = 2 means we are querying if our menu_id is handled by the sendto menu. returns 0xffffffff if it was.
  54. // mode = 3 means we are sending the data. return value is not important =)
  55. // be sure to have set data_type, menu_id, and data, for this one.
  56. // mode = 4 means to cleanup this structure.
  57. // build parms
  58. HMENU build_hMenu; // set this to the HMENU
  59. int build_start_id; // override the start and endpoints of IDs it can use
  60. int build_end_id; // or leave as 0s for defaults.
  61. // type used for build and send modes (ML_TYPE_*)
  62. int data_type;
  63. int menu_id;
  64. void *data; // only used in mode = 3
  65. HWND hwnd; // parent for sendto
  66. // specify ctx[1]=1 to disable 'enqueue in winamp' on the menu
  67. // specify ctx[2]=(ML_TYPE_*)+1 as the originally intended data_type
  68. intptr_t ctx[32]; // internal winamp use
  69. } librarySendToMenuStruct;
  70. //IPC_GETMLWINDOW
  71. //int IPC_GETMLWINDOW=SendMessage(hMainWindow,WM_WA_IPC,(WPARAM)&"LibraryGetWnd",IPC_REGISTER_WINAMP_IPCMESSAGE);
  72. //
  73. //then:
  74. // to ensure library's db is loaded: if (IPC_GETMLWINDOW>65536) SendMessage(hMainWindow,WM_WA_IPC,-1,IPC_GETMLWINDOW);
  75. // or to get the HWND of the library (for library APIs): HWND hwndlib = IPC_GETMLWINDOW>65536 ? SendMessage(hMainWindow,WM_WA_IPC,0,IPC_GETMLWINDOW) : 0;
  76. #endif//_WA_ML_IPC_H_