Help - Search - Members - Calendar
Full Version: WM_DROPFILES
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
danZ
I have this code for my window

CODE

   LRESULT OnDrop(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
   {
 TCHAR buffer[MAX_PATH + 1];
 HDROP hDrop = (HDROP)wParam;

 int numOfFiles = DragQueryFile(hDrop, 0xFFFFFFFF, buffer, MAX_PATH);

 if (numOfFiles == 1)
 {
  memset(buffer, 0, sizeof(buffer));
  int bufsize = DragQueryFile(hDrop, 0, buffer, MAX_PATH);
  if(bufsize > 0)
  {
   String filename(buffer);
   if (filename.Mid(filename.GetLength()-4).CompareNoCase(_T(".ski")) == 0)
   {
    SavePlacement();
    if (cfg_active == 0)
     cfg_primary_look = string_utf8_from_os((LPCTSTR)buffer);
    else
     cfg_secondary_look = string_utf8_from_os((LPCTSTR)buffer);
    LoadSkin();
    return TRUE;
   }
  }
 }

 bHandled = FALSE;
 ::SendMessage(service_factory_base::get_main_window(),WM_DROPFILES,wParam,lParam);
 return TRUE;
   }


In the past it would load a new look if the extension matched or forward the WM_DROPFILES to foobar which was nice since you could drop playlists, mp3 files, etc. on my window and they'd get processed by foobar.

Doesn't work any more wrt to passing to foobar.

Does foobar doing something different with WM_DROPFILES now?
Peter
QUOTE("0.7 changelog")
- improved handling of drag&drop operations, now supports dropping URLs from browser
It now uses IDropTarget interface instead.
Whatever you're trying to do it is seriously wrong, you should call playlist_oper methods instead.
danZ
QUOTE(zZzZzZz @ Jan 6 2004, 03:07 PM)
QUOTE("0.7 changelog")
- improved handling of drag&drop operations, now supports dropping URLs from browser
It now uses IDropTarget interface instead.
Whatever you're trying to do it is seriously wrong, you should call playlist_oper methods instead.

It wasn't all bad when it worked because the main UI would take care the drop message including creating the thread to load all the files, etc. and I only had one line of code in my component. Now, I have to implement all that unless playlist_oper takes care of it.

I'll look into it.

Thanks.
Peter
playlist_oper does take care of it.
(hint: playlist_oper::add_locations() )
danZ
QUOTE(zZzZzZz @ Jan 6 2004, 03:13 PM)
playlist_oper does take care of it.
(hint: playlist_oper::add_locations() )

Thanks,

When would you use

playlist_loader::process_path_ex() etc.?
Peter
playlist_oper::add_locations() already does it, in a separate thread, and displays a nice progress dialog.
(hmm i should make separate API for that someday)
danZ
QUOTE(zZzZzZz @ Jan 6 2004, 03:23 PM)
playlist_oper::add_locations() already does it, in a separate thread, and displays a nice progress dialog.
(hmm i should make separate API for that someday)

I'm getting empty entries

What is the format of the string you pass in?

CODE
 ptr_list_t<const char> files;
 for (int f = 0; f < numOfFiles; f++)
 {
  memset(buffer, 0, sizeof(buffer));
  int bufsize = DragQueryFile(hDrop, f, buffer, MAX_PATH);
  if(bufsize > 0)
  {
   String filename(buffer);
   if (filename.Find(_T("://")) == -1)
    filename = _T("file://") + filename;

   files.add_item(string_utf8_from_os(filename));
  }  
 }

 playlist_oper::get()->add_locations(files);

Peter
You are basically passing invalid pointers.
Quick-and-dirty solution:
strdup them when adding to the list:
CODE
files.add_item(strdup(string_utf8_from_os(filename)));

Then free after add_locations() has returned:
CODE
{
 unsigned n,m=files.get_count();
 for(n=0;n<m;n++) free((void*)files.get_item(n));
}
danZ
QUOTE(zZzZzZz @ Jan 6 2004, 03:43 PM)
You are basically passing invalid pointers.
Quick-and-dirty solution:
strdup them when adding to the list:
CODE
files.add_item(strdup(string_utf8_from_os(filename)));

Then free after add_locations() has returned:
CODE
{
 unsigned n,m=files.get_count();
 for(n=0;n<m;n++) free((void*)files.get_item(n));
}

Yes, that worked, thanks.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.