I’m working on an app where I'd like to be able to drop a file to this control, process the file, and then deposit the result into the folder selected in the control.
The stock treeview doesn’t appear to support hot select when dragging a file and the Foldertree control seems pretty limited also.
VB.Net has a thing called an “Explorer tree controlâ€.
Is this going to turn out to be a custom control or are there other options out there?
Thanks for your help!
Bob
Robert,
See if this is close to what you are looking for.
Paul,
I had to manually tell the control to accept files even after checking WS_EX_ACCEPTFILES in the WindowsStyles properties.
I just made a call to SetWindowLong in the FormCreate message.
David
David,
Thanks for the file. It's definitely a useful example for me.
Ideally it would also tell you the destination folder (by where the file was dropped in the tree). And if needed, expands the tree when the mouse hovers over it, like Windows File Explorer works.
A workaround might be to have the user click the destination folder after dropping the file, but of course not quite as nice
My ultimate goal is actually to drag messages out of Outlook and then file away the message and any attachments.
Thanks,
Bob
Okay this is really making my head hurt :-[ I can't believe it would be this hard.
So I'm thinking a listview might work better than a tree or folder view, but it has the same problem. If I am dragging a file to it, there seems to be no easy way to know which item in the list it gets dropped on. Hot select and WM_MOUSEMOVE doesn't fire in the control or the form when your dragging a file.
I suppose that I could use GetCursorPos, figure out the font size in the control, calculate which item the mouse is over, and then select the appropriate item in the list with FF_ListView_SetSelectedItem. That seem like a lot of work.
Before I go down that path I'd like to know if I'm missing something obvious.
Thanks,
Bob
Robert,
You have to remember that the active program is the one you are dragging files from. You can use OLE to register your control as wanting drag-n-drop info. I modified a PB program written by Semen Matusovski (based on some C code) as a proof of concept for myself last week. I never integrated it into the FF demo I put together for you. He was dragging Links I believe, and I modified it to work with files. As you will see, it can tell when files are being dragged over it (Semen's code only detected the drop).
The control is an edit box, but there is no reason you couldn't make it a TreeView or ListView. You would have to write the routines to determine if the user was hovering over an item and take the appropriate action (expand the node, collapse the node, etc.). Have a look at it.
If you take it further, please take the time to show us a demo of it.
David
Thanks David,
This is really the root of the problem:
Quote from: David Kenny on March 03, 2011, 06:33:38 AM
You would have to write the routines to determine if the user was hovering over an item and take the appropriate action (expand the node, collapse the node, etc.).
I've written VB programs in the past that supported drag and drop. Here's an old one now:
http://festus440.happypalm.com/zl_icons.php (http://festus440.happypalm.com/zl_icons.php)
However I've never had to drop a file to an item "within" a control. Since I'm new to this SDK stuff I was hoping someone was aware of a message from the listview control that would indicate what item the mouse was over
during a drag operation.
Getting the item using x & y coordinates seems like a bit of a kludge, but perhaps that is the only option short of creating a list view control from scratch. When I get a framework of something together I will post it.
Robert,
The program you wrote that supported drag and drop... was this drag from another program to yours? or from one control to another control (both in your program)?
In the other programs the users drop files from Explorer or the desktop into the program.
That is what I'm doing now also, but the ultimate goal will be to drag messages from Outlook. You can already drag messages out of Outlook directly to a folder but I want to make it a little more convienient and perhaps add options on how to deal with attachments.
The company I work for is going to require that we store project related messages in project folders on the network instead of using the folders inside Outlook (that get stored in a .pst file). So I am essentially trying to duplicate the folder structure in Outlook but have the folders capable being assigned to different locations or even different drives. When I get to that point I'm probably going to try using something like Outlook Redemption.
"say the secret word and win a hundred dollars" :D (showing my age)
And the secret word is TVM_HITTEST.
With a treeview using GetCursorPos along with the Treeview_HitTest function and TV_HITTESTINFO I can get a handle to an item in the tree that the mouse is over even when a mousebutton is down (in other words, while draging a file to the control). With that info I can hopefully start to do some stuff.