Menu

#889 IDropTargetHelper support

Won't_Implement
open
None
2
2012-01-16
2012-01-12
No

Adding IDropTargetHelper to the drop target interfaces in scintillawin.cxx would improve visual feedback during drag-and-drop. Adding this implements the thumbnail overlay effect that you see if you drag files from the Windows desktop over another folder window, or over a Chrome browser window, e.g. Without this, you just get the "plus" cursor, for example, with no thumbnail of the object being dragged.

This probably isn't too exciting for the basic editor control, but it's really easy to add, and it's useful when the control is embedded in an application. My specific use case is that I implement file drag-and-drop in my app container, so that if you drop a file from the Windows desktop onto an existing editor window, my app opens that file in a new editor window. Adding the IDropTargetHandler code makes the file drag visually seamless, since you get the same visual effect within the Scintilla window that the Windows desktop shows while the cursor is over a folder window or over the desktop background.

Here are the exact source changes involved:

1. #include <shlobj.h> with the other win32 includes

2. add a new ScintillaWin member variable: IDropTargetHelper *dthelper; (suggest after DropTarget dt;)

3. in ScintillaWin::ScintillaWin(), add just about anywhere: dthelper = 0;

4. in ScillaWin::Finalise(), add after ::RevokeDragDrop: if (dthelper != 0) dthelper->Release();

5. in ScintillaWin::WndProc(), after ::RegisterDragDrop, add:
CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER, IID_IDropTargetHelper, (LPVOID *)&dthelper);

6. In ScintillaWin::DragEnter, add a variable name ('pt') for the POINTL param

7. In ScintillaWin::DragEnter(), at the top, add:
if (dthelper != 0)
{
POINT pts = { pt.x, pt.y };
dthelper->DragEnter(MainHWND(), pIDataSource, &pts, *pdwEffect);
}

8. In ScillaWin::DragOver, add as the first thing inside the try { }:
if (dthelper != 0)
{
POINT pts = { pt.x, pt.y };
dthelper->DragOver(&pts, *pdwEffect);
}

9. In ScintillaWin::DragLeave(), add first thing inside the try { }:
if (dthelper != 0) dthelper->DragLeave();

10. In ScintillaWin::Drop, add first thing inside the try { }:
if (dthelper != 0)
{
POINT pts = { pt.x, pt.y };
dthelper->Drop(pIDataSource, &pts, *pdwEffect);
}

Discussion

  • Neil Hodgson

    Neil Hodgson - 2012-01-16

    Feature #3472846 covers this in a different way.

     
  • Neil Hodgson

    Neil Hodgson - 2012-01-16
    • assigned_to: nobody --> nyamatongwe
    • priority: 5 --> 2
    • milestone: --> Won't_Implement
     

Log in to post a comment.