Go Back   Winamp Forums > Developer Center > Winamp Development

Reply
Thread Tools Search this Thread Display Modes
Old 19th September 2005, 19:22   #1
dllmain
Senior Member
 
dllmain's Avatar
 
Join Date: Sep 2005
Location: Berlin, Germany
Posts: 207
how do i get the playlist selection?

is there an equivalent for LB_GETSELITEMS or something?
or can i check if a certain playlist item is selected?


thanx in advance!
dllmain is offline   Reply With Quote
Old 19th September 2005, 21:49   #2
DrO
-
 
DrO's Avatar
 
Join Date: Sep 2003
Location: UK
Posts: 22,210
will only work on a 5.x install (this should be the version that shaneh was happy with)

-daz
Attached Files
File Type: txt sel.txt (1.9 KB, 177 views)
DrO is offline   Reply With Quote
Old 20th September 2005, 03:09   #3
dllmain
Senior Member
 
dllmain's Avatar
 
Join Date: Sep 2005
Location: Berlin, Germany
Posts: 207
thanx for the code dro, but there are several things which i don't understand here. among them
  • what does line 23 "DWORD plpos = *((DWORD*)wp + 8);" do and why
  • where is "fileinfo2" defined
  • what is the value of IPC_PE_GETINDEXTITLE
dllmain is offline   Reply With Quote
Old 20th September 2005, 04:26   #4
crackity
Senior Member
 
Join Date: Jul 2004
Location: The East Side
Posts: 120
Send a message via ICQ to crackity Send a message via AIM to crackity
Quote:
Originally posted by dllmain
thanx for the code dro, but there are several things which i don't understand here. among them
  • what does line 23 "DWORD plpos = *((DWORD*)wp + 8);" do and why
  • where is "fileinfo2" defined
  • what is the value of IPC_PE_GETINDEXTITLE
well wp is a pointer to a waHookTitleStruct and since that is defined as:

typedef struct
{
char *filename;
char *title; // 2048 bytes
int length;
int force_useformatting; // can set this to 1 if you want to force a url to use title formatting shit
} waHookTitleStruct;


wp + 8 is a pointer to the length (skipping over the first 2 char*'s in the struct.... since we are stuck in 32 bit, they are each 4 bytes hence the 2*4) and *(wp+8) is the length...... now as to why it actually is the playlist position and not the length beats the hell out of me.... lol....well also why they dont just reference it as wahts->length beats me too

the two missing defines (fileinfo2, IPC_PE_GETINDEXTITLE) are in ipc_pe.h.... which is included with the SDK

Crackity
QuickTracks: Info & Most Recent
crackity is offline   Reply With Quote
Old 20th September 2005, 05:43   #5
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Actually it is referencing something outside of that structure, a value that is pushed on the stack for a function before calling yours through sendmessage. wParam just convienently is also pushed on the stack for the same function - so you can use wParam to find where on the stack to look.

Basically, you shouldnt have access to it, but I traced through the code and saw that this position is placed on the stack for you to take off - it could be changed at any time in theory - but I can't see it happening, there arne't too many changes like this happening with Winamp at the moment.

Be aware that this trick won't work if format titles using ATF is disabled.
shaneh is offline   Reply With Quote
Old 20th September 2005, 16:44   #6
crackity
Senior Member
 
Join Date: Jul 2004
Location: The East Side
Posts: 120
Send a message via ICQ to crackity Send a message via AIM to crackity
how is it not something in the struct?

waHookTitleStruct *wahts = (waHookTitleStruct*)wp;
DWORD plpos = *((DWORD*)wp + 8);

this is assuming wp really is a passed in waHookTitleStruct struct(just from looking at the code).

the entire struct will be in one continuous place in memory (of course taking into account of keeping things aligned) so 8 bytes from the start of the struct is still inside the struct and should be where the length is stored.

in other words you can rewrite those two lines as:

waHookTitleStruct *wahts = (waHookTitleStruct*)wp;
DWORD plpos = *((DWORD*)wahts + 8);

and how is *(wahts + 8) different then wahts->length in this case?

lol, anyhow, now time to wait and learn something :P

Crackity
QuickTracks: Info & Most Recent
crackity is offline   Reply With Quote
Old 20th September 2005, 17:12   #7
dllmain
Senior Member
 
dllmain's Avatar
 
Join Date: Sep 2005
Location: Berlin, Germany
Posts: 207
Quote:
the two missing defines (fileinfo2, IPC_PE_GETINDEXTITLE) are in ipc_pe.h.... which is included with the SDK [/B]
i never looked at that file, my bad.

Quote:
how is it not something in the struct?
i think shaneh is right here:

"(DWORD*)wp + 8" means wp is used as a DWORD-pointer.
this affects pointer arithmetic: wp++ would increase
4 bytes, so wp+8 increases 8*sizeof(DWORD) == 32 bytes.
dllmain is offline   Reply With Quote
Old 20th September 2005, 18:23   #8
crackity
Senior Member
 
Join Date: Jul 2004
Location: The East Side
Posts: 120
Send a message via ICQ to crackity Send a message via AIM to crackity
grrr duh

Crackity
QuickTracks: Info & Most Recent
crackity is offline   Reply With Quote
Old 23rd September 2005, 00:44   #9
dllmain
Senior Member
 
dllmain's Avatar
 
Join Date: Sep 2005
Location: Berlin, Germany
Posts: 207
i was able to fully test dro's code now.
i simplified it a little (see at the end).

shaneh was right - it only works with ATF enabled.
i originally needed to get the playlist selection to be
able to replace the "edit playlist entry" dialog but i
now use a solution modifing the existing dialog which
also works with ATF off.

thanx again for your help!


code:

LRESULT CALLBACK WndprocMain( HWND hwnd, UINT message, WPARAM wp, LPARAM lp )
{
switch( message )
{
case WM_WA_IPC:
if( ( lp == IPC_HOOK_TITLES ) && bSelHook )
{
waHookTitleStruct * wahts = ( waHookTitleStruct* )wp;
DWORD plpos = *( ( DWORD* )wp + 8 );

// Let Winamp fill the info
LRESULT res = CallWindowProc( WndprocMainBackup, hwnd, message, wp, lp );

char szBuffer[ 5000 ];
sprintf(
szBuffer,
"Number\t\t%i\n"
"\n"
"Filename\t\t%s \n"
"\n"
"Title\t\t%s \n"
"\n"
"Length\t\t%02i:%02i",
plpos + 1,
wahts->filename,
wahts->title,
wahts->length / 60,
wahts->length % 60
);
MessageBox( 0, szBuffer, "Selection info", 0 );

return res;
}
}
return CallWindowProc( WndprocMainBackup, hwnd, message, wp, lp );
}


dllmain is offline   Reply With Quote
Reply
Go Back   Winamp 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