Old 12th March 2010, 14:52   #1
Tsuyo
Junior Member
 
Join Date: Dec 2009
Posts: 37
Remove playlistitem: 5

Hi.
How do i remove a specific Playlist item via Sendmessage?

greetings
Tsuyo is offline   Reply With Quote
Old 12th March 2010, 17:10   #2
thinktink
Forum King
 
thinktink's Avatar
 
Join Date: May 2009
Location: No longer on the streets of Kings County, CA.
Posts: 3,199
include the "ipc_pe.h" header which contains the following declaration:

code:
#define IPC_PE_DELETEINDEX 104 // lParam = index


You need to retrieve the HWND of the playlist editor first and then call the documented API entry

code:
SendMessage(HWND_to_playlist_editor,WM_WA_IPC,IPC_PE_DELETEINDEX,item_index);
thinktink is offline   Reply With Quote
Old 12th March 2010, 17:18   #3
Tsuyo
Junior Member
 
Join Date: Dec 2009
Posts: 37
Thank you for your fast help!

Greetings
Tsuyo
Tsuyo is offline   Reply With Quote
Old 12th March 2010, 18:01   #4
Tsuyo
Junior Member
 
Join Date: Dec 2009
Posts: 37
/edit:
Here is the working code:
code:

SendMessage((HWND)SendMessage(plugin.hwndParent,WM_WA_IPC,IPC_GETWND_PE,IPC_GETWND) ,WM_WA_IPC ,IPC_PE_DELETEINDEX , 1);

Tsuyo is offline   Reply With Quote
Old 12th March 2010, 18:43   #5
thinktink
Forum King
 
thinktink's Avatar
 
Join Date: May 2009
Location: No longer on the streets of Kings County, CA.
Posts: 3,199
Syntactically that looks correct but it's dangerous not checking the return value of the playlist editor HWND first before calling the IPC_PE_DELETEINDEX API. In this form if the return value of IPC_GETWND call is invalid (say like 0xFFFFFFFF (WHND_BROADCAST) or 0x00000000 (I think the Win98 Desktop Handle, not sure though)) you could potentially be sending a message to a very wrong place. Plus the fact every time you call that you're calling SendMessage two times every time which isn't as efficient as it could be. Storing the pe HWND in a seperate (global if you like) variable is strongly recommended.

code:

parent = plugin.hwndParent;
pe = (HWND)SendMessage(parent,WM_WA_IPC,IPC_GETWND_PE,IPC_GETWND);
if(!IsWindow(pe))
{
pe=FindWindow("Winamp PE",0);
if(!IsWindow(pe))
{
pe=NULL;
}
}




Just an example.

/edit:
removed superfluous code.

Last edited by thinktink; 12th March 2010 at 19:00.
thinktink is offline   Reply With Quote
Old 12th March 2010, 19:06   #6
DrO
 
Join Date: Sep 2003
Posts: 27,873
it's safe to go with what Tsuyo posted for getting the hwnd as if that fails then Winamp probably won't be running correctly in the first place unless pre 2.9x support is required (and people are mad to be catering for such old clients now anyway).

it just requires ensuring the plug-in is version checking that it's running on a supporting client version - best done on init(). which would be anything below 0x2900 when compared to IPC_GETVERSION. plus from what Tsuyo is using elsewhere with regards to api usage, 0x5000 is the minimum to be running on anyway (ahd probably higher if i check through some older posts).

-daz
DrO is offline   Reply With Quote
Old 12th March 2010, 19:21   #7
Tsuyo
Junior Member
 
Join Date: Dec 2009
Posts: 37
my "users" are all over the 5.0 range
Tsuyo is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump