Ok, here's a little class that will take care of the implementation.
Just be sure to place the Allow() function under your WM_DROPFILES handler, and pass it your WPARAM.
Enjoy.
Code:
class DragDrop {
public:
int file_count;
String * files;
void Allow(HWND hwnd) {
DragAcceptFiles(hwnd, TRUE);
}
bool Accept(WPARAM wp) {
if( files ){
delete [] files;
}
iter = 0;
data = (HDROP)wp;
file_count = DragQueryFile(data, 0xFFFFFFFF, NULL, 0);
files = new String[ file_count ];
if( files == NULL ){
return false;
}
while(iter < file_count) {
DragQueryFile(data, iter, buffer, 256);
files[iter++] = buffer;
}
DragFinish(data);
return true;
}
DragDrop()
:files(NULL) {
/* */
}
~DragDrop() {
if( files ){
delete [] files;
}
}
private:
HDROP data;
int iter;
char buffer[256];
};