Jump to content

How to drag a filename from a ListView?


qwert
 Share

Recommended Posts

I've used the $WS_EX_ACCEPTFILES features a number of times, so that a user can drag a file name from explorer directly to a control on a GUI.  Everything has always worked.

But now I have an instance where a ListView contains the full file paths of files that the user can select for processing.  But I can't get drag and drop to work.

I can select a file in the ListView by clicking on it.  The file name highlights and the cursor changes to indicate a drag is in progress.  And a drop event occurs for the destination control.  But no filename is passed in @GUI_DragFile.  It is blank.  In other words, the drag operation looks like it works, but it doesn't.

Can anyone shed some light on this?  I can't locate any examples other than dragging items within the ListView.  Yet, I can't believe this isn't a common action.

Thanks in advance for any help.

Drag from ListView.PNG

Link to comment
Share on other sites

Every indication (that I've found) seems to confirm that drag and drop isn't available for ListViews.

Quote

"This problem occurs because the ListView control does not support drag-and-drop functionality for the items at run time."—msdn

As an alternative, I found this code snippet by GEOsoft from 10 years ago:

$Idx = Int(_GUICtrlListView_GetSelectedIndices($Listview1))
$i_Txt = _GUICtrlListView_GetItemText($Listview1, $Idx)
msgBox(0, "TEST", $i_Txt)

With some careful "qualification" statements, I've been able to incorporate this "grab line" operation with the "drop nothing" action to solve my immediate need.

I'm open to other suggestions, of course, but I have to move on to other tasks.  For now, this simple alternative will suffice.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...