1
0

ipc_pe.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #ifndef __IPC_PE_H
  2. #define __IPC_PE_H
  3. /*
  4. ** To use these messages you will need a valid window handle for the playlist window
  5. ** and the format to use them is:
  6. **
  7. ** SendMessageW(playlist_wnd,WM_WA_IPC,IPC_*,(parameter));
  8. **
  9. ** Note:
  10. ** This IS the OPPOSITE way to how the messages to the main winamp window are sent
  11. ** SendMessageW(hwnd_winamp,WM_WA_IPC,(parameter),IPC_*);
  12. */
  13. /*
  14. ** Playlist Window:
  15. **
  16. ** To get the playlist window there are two ways depending on the version you're using
  17. **
  18. ** HWND playlist_wnd = 0;
  19. ** int wa_version = SendMessageW(plugin.hwndParent,WM_WA_IPC,0,IPC_GETVERSION);
  20. **
  21. ** if(wa_version >= 0x2900)
  22. ** {
  23. ** // use the built in api to get the handle
  24. ** playlist_wnd = (HWND)SendMessageW(plugin.hwndParent,WM_WA_IPC,IPC_GETWND_PE,IPC_GETWND);
  25. ** }
  26. **
  27. ** // if it failed then use the old way :o)
  28. ** if(!IsWindow(playlist_wnd))
  29. ** {
  30. ** playlist_wnd = FindWindow("Winamp PE",0);
  31. ** }
  32. */
  33. /*
  34. ** Structures used by some of the apis referenced.
  35. */
  36. typedef struct {
  37. char file[MAX_PATH];
  38. int index;
  39. } fileinfo;
  40. typedef struct {
  41. wchar_t file[MAX_PATH];
  42. int index;
  43. } fileinfoW;
  44. typedef struct {
  45. HWND callback;
  46. int index;
  47. } callbackinfo;
  48. typedef struct {
  49. int fileindex;
  50. char filetitle[256];
  51. char filelength[16];
  52. } fileinfo2;
  53. typedef struct {
  54. int fileindex;
  55. wchar_t filetitle[256];
  56. wchar_t filelength[16];
  57. } fileinfo2W;
  58. #define IPC_PE_GETCURINDEX 100 // returns current idx (typically the playing item)
  59. #define IPC_PE_GETINDEXTOTAL 101 // returns the number of items in the playlist
  60. #define IPC_PE_GETINDEXINFO 102 // (copydata) lpData is of type callbackinfo, callback is called with copydata/fileinfo structure and msg IPC_PE_GETINDEXINFORESULT
  61. #define IPC_PE_GETINDEXINFORESULT 103 // callback message for IPC_PE_GETINDEXINFO
  62. #define IPC_PE_DELETEINDEX 104 // lParam = index
  63. #define IPC_PE_SWAPINDEX 105 // (lParam & 0xFFFF0000) >> 16 = from, (lParam & 0xFFFF) = to
  64. /*
  65. ** SendMessageW(playlist_wnd,WM_WA_IPC,IPC_PE_SWAPINDEX,MAKELPARAM(from,to));
  66. */
  67. #define IPC_PE_INSERTFILENAME 106 // (copydata) lpData is of type fileinfo
  68. #define IPC_PE_INSERTFILENAMEW 114 // (copydata) lpData is of type fileinfoW (5.3+)
  69. /* COPYDATASTRUCT cds = {0};
  70. ** fileinfo f = {0};
  71. **
  72. ** lstrcpyn(f.file, file,MAX_PATH); // path to the file
  73. ** f.index = position; // insert file position
  74. **
  75. ** cds.dwData = IPC_PE_INSERTFILENAME;
  76. ** cds.lpData = (void*)&f;
  77. ** cds.cbData = sizeof(fileinfo);
  78. ** SendMessageW(playlist_wnd,WM_COPYDATA,0,(LPARAM)&cds);
  79. */
  80. #define IPC_PE_GETDIRTY 107 // returns 1 if the playlist changed since the last IPC_PE_SETCLEAN
  81. #define IPC_PE_SETCLEAN 108 // resets the dirty flag until next modification
  82. #define IPC_PE_GETIDXFROMPOINT 109 // pass a point param and will return a playlist index (if in the area)
  83. /*
  84. ** POINT pt;
  85. ** RECT rc;
  86. **
  87. ** // Get the current position of the mouse and the current client area of the playlist window
  88. ** // and then mapping the mouse position to the client area
  89. ** GetCursorPos(&pt);
  90. **
  91. ** // Get the client area of the playlist window and then map the mouse position to it
  92. ** GetClientRect(playlist_wnd,&rc);
  93. ** ScreenToClient(playlist_wnd,&pt);
  94. **
  95. ** // this corrects so the selection works correctly on the selection boundary
  96. ** // appears to happen on the older 2.x series as well
  97. ** pt.y -= 2;
  98. **
  99. ** // corrections for the playlist window area so that work is only done for valid positions
  100. ** // and nicely enough it works for both classic and modern skin modes
  101. ** rc.top += 18;
  102. ** rc.left += 12;
  103. ** rc.right -= 19;
  104. ** rc.bottom -= 40;
  105. **
  106. ** // is the click in
  107. ** if(PtInRect(&rc,pt))
  108. ** {
  109. ** // get the item index at the given point
  110. ** // if this is out of range then it will return 0 (not very helpful really)
  111. ** int idx = SendMessageW(playlist_wnd,WM_WA_IPC,IPC_PE_GETIDXFROMPOINT,(LPARAM)&pt);
  112. **
  113. ** // makes sure that the item isn't past the last playlist item
  114. ** if(idx < SendMessageW(playlist_wnd,WM_WA_IPC,IPC_PE_GETINDEXTOTAL,0))
  115. ** {
  116. ** // ... do stuff in here (this example will start playing the selected track)
  117. ** SendMessageW(plugin.hwndParent,WM_WA_IPC,idx,IPC_SETPLAYLISTPOS);
  118. ** SendMessageW(plugin.hwndParent,WM_COMMAND,MAKEWPARAM(WINAMP_BUTTON2,0),0);
  119. ** }
  120. ** }
  121. */
  122. #define IPC_PE_SAVEEND 110 // pass index to save from
  123. #define IPC_PE_RESTOREEND 111 // no parm
  124. #define IPC_PE_GETNEXTSELECTED 112 // same as IPC_PLAYLIST_GET_NEXT_SELECTED for the main window
  125. #define IPC_PE_GETSELECTEDCOUNT 113
  126. #define IPC_PE_GETINDEXINFO_TITLE 115 // like IPC_PE_GETINDEXINFO, but writes the title to char file[MAX_PATH] instead of filename
  127. #define IPC_PE_GETINDEXINFORESULT_TITLE 116 // callback message for IPC_PE_GETINDEXINFO
  128. // the following messages are in_process ONLY
  129. #define IPC_PE_GETINDEXTITLE 200 // lParam = pointer to fileinfo2 struct
  130. #define IPC_PE_GETINDEXTITLEW 201 // lParam = pointer to fileinfo2W struct
  131. /*
  132. ** fileinfo2 file;
  133. ** int ret = 0;
  134. **
  135. ** file.fileindex = position; // this is zero based!
  136. ** ret = SendMessageW(playlist_wnd,WM_WA_IPC,IPC_PE_GETINDEXTITLE,(LPARAM)&file);
  137. **
  138. ** // if it returns 0 then track information was received
  139. ** if(!ret)
  140. ** {
  141. ** // ... do stuff
  142. ** }
  143. */
  144. #define IPC_PE_GETINDEXINFO_INPROC 202 // lParam = pointer to fileinfo struct
  145. #define IPC_PE_GETINDEXINFOW_INPROC 203 // lParam = pointer to fileinfoW struct
  146. #endif