PDA

View Full Version : [Q:coding] make plugin recognize dragNdrop


tecxx
7th April 2002, 14:15
Hello!

I want to write a plugin which is notified when a user DRAG&DROPS a new file in the winamp window or playlist.

I checked the plugin samples, i know quite a bit about windows coding, but:

1) should such a plugin be an INPUT plugin or a GENERAL plugin?

2) is such a plugin possible at all? (does winamp tell its plugins about the users actions?)

3) can anyone help me with a piece of code on this problem? I understand the samples, how they work, and the interface to winamp, but i don't have the slightest idea where to start.


what I want to do:
there is a very cool plugin for playing out of a zip file (thanx peter) but its not easy to use. so i want to write a plugin that simply adds all the files from a .zip file to the playlist if the user drag&drops the zip file into the winamp window.

i know how to do adding to the playlist, reading the zip etc etc, i just don't know how to catch the drag & drop event.


any comments welcome
tecxx

Rocker
7th April 2002, 14:43
1. general....

2. what language

3. what language

tecxx
7th April 2002, 15:04
sorry for posting in the wrong forum :(

c++/c/mfc ... i'm using visual studio.

i played around a bit and i guess the best way is to intercept the WndProc of winamp by supplying my own one, right?

voodoopriestess
8th April 2002, 00:13
In C - it's a fairly painless procedure...

1. Call DragAcceptFiles (HWND, BOOL) with the handle to the WinAMP window and true to enable dropped files.

2. Call GetWindowLong (HWND, int) with the handle to the WinAMP window and GWL_WNDPROC. This returns a 32 bit long than contains the address of the WinAMP window procedure.

3. Create a window procedure than parses WM_DROPFILES and via the SetWindowLong (HWND, int, long) set the new WNDPROC of the WinAMP window to point at this.

4. If you process the WM_DROPFILES successfully - i.e. you do something; return 0 otherwise call CallWindowProc (WNDPROC, HWND, UINT, WPARAM, LPARAM) where the WNDPROC is the cast long that you got from GetWindowLong () and the HWND is the handle to the WinAMP window.

This should do everything that you need bar process the actual dropped file. Now you should note that this does not take into account whether WinAMP has already set a drop function. If so, becareful what you do the data in the WPARAM and LPARAM variables. There may be dependancies that you are not aware of.

This does not take account of any MFC predelictions that you may have - it performs a pure Win32 API processing of Shell Drag 'n' Drop.

Have fun - Iain

voodoopriestess
8th April 2002, 00:22
/* WARNING: UNTESTED CODE */

LONG g_lOldWndProc;
LRESULT CALLBACK DragDrop_WndProc (HWND, UINT, WPARAM, LPARAM);

void init ()
{
// SDKVar is the variable used to contain the
// function prototypes that WinAMP uses.
DrapAccept (SDKVar.hMainWindow, true);
g_lOldWndProc = GetWindowLong (SDKVar.hMainWindow, GWL_WNDPROC);
SetWindowLong (SDKVar.hMainWindow, GWL_WNDPROC, (long) DragDrop_WndProc);
}

LRESULT CALLBACK DragDrop_WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_DROPFILES:
//
// Process the files dropped. Return 0 if we processed the
// message.
//
return 0;

default:
//
// For everything else.
//
CallWindowProc ((LRESULT) g_lOldWndProc, hWnd, uMsg, wParam, lParam);
}
}

Iain

tecxx
8th April 2002, 19:53
thanks alot. the plugin is nearly done.

is there a way to intercept the message procedure of the playlist? currently all is fine, but in winamp's main window only.

i'm posting the sourcecode when its done.

thanks again,
tecxx

tecxx
8th April 2002, 20:34
so, if anyones interested:

http://www.rrs.at/winamp/

here's the plugin and the sourcecode.

voodoopriestess
8th April 2002, 23:26
In addition to the previous code...

/* UNTESTED - use at own risk. Wyle E Coyote style */

// Secure a handle to the playlist window via it's window name and
// class id. See Spy++ to get more info.
HWND hPlaylist = FindWindow ("Winamp Playlist Editor", "Winamp PE");

// Enable the playlist to accept files and spawn a WM_DROPFILES
// message when files are dropped on it.
DragAcceptFiles (hPlaylist, true);

// Retrieve the current WNDPROC and save it in the global variable.
g_lOldWndProc = GetWindowLong (hPlaylist, GWL_WNDPROC);

// Set the new window procedure to our drag and drop interceptor.
SetWindowLong (hPlaylist, GWL_WNDPROC, (long) DragDrop_WndProc);

Hope this helps. By the way use FindWindow ("Winamp Equalizer", "Winamp EQ") for the equaliser window.

Iain

tecxx
9th April 2002, 06:13
ok stupid me. a bit more brain activity and i could have done that myself :=)
thanks.

tecxx
9th April 2002, 17:57
updated and working:
http://rrs.at/winamp

thanks for all the help.
tecxx