Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Drag and Drop (Read 3229 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Drag and Drop

Hi everyone,
I'm trying to make a plugin out of an application I'm working on. The app in question supports drag and drop, basically using this:
Code: [Select]
    case WM_DROPFILES:
    {
 // Drag and drop code
 WORD m_iNumberOfFiles, i;
 TCHAR m_file[STRLIMIT2]=_T("");
 TCHAR m_files[STRLIMIT3]=_T("");

 m_iNumberOfFiles = DragQueryFile((HDROP) wParam, 0xFFFFFFFF, NULL, 0);
 if (m_iNumberOfFiles==1)
 {
     DragQueryFile( (HDROP) wParam, 1, m_file, sizeof(m_file));
     _tcscpy(m_files, m_file);
     bMultiSelect=FALSE;
 }
 else
 {
     for(i = 0; i < m_iNumberOfFiles; i++)
     {
   DragQueryFile( (HDROP) wParam, i, m_file, sizeof(m_file));
   _tcscat(m_files, _T("\""));
   _tcscat(m_files, m_file);
   _tcscat(m_files, _T("\" "));
     }
     bMultiSelect=TRUE;
 }

 DragFinish((HDROP) wParam);

 SetDlgItemText(wnd, IDC_EDIT1, m_files);
    }
    break;

Unfortunately, when I drag some files and drop them in the plugins dialog, the above code is invariably ignored and the files added to the current playlist. Would be helpful if you had an idea on this one =)

edit: to add that it uses the context menu command (like foo_infobox).

Drag and Drop

Reply #1
The default UI (and presumably foo_ui_columns as well) register an OLE drop handler for the main window. So if you make your window a child of the main window, the drop handler of the main window will be invoked, and no WM_DROPFILES messages is sent.

There are two possible solutions to this problem:
  • Don't make you window a child of the main window, though this is probably not what you want.
  • Write your own drop handler. This requires some more effort.
    If you haven't worked with OLE's IDropTarget interface yet, you can have a look at my foo_tutorial2 prototype. drop_dispatcher.cpp contains an implementation of IDropTarget that does nothing when something is dropped. drop_handler shows how to extract a HDROP handle from an IDataObject.

Drag and Drop

Reply #2
Wow that's ingenious thanks, I'll try and implement the handler on monday.
However, if I may, isn't it a potential source of conflict if 2 plugins use different handlers?

 

Drag and Drop

Reply #3
Not if those handlers are registered for different windows.