sparti Posted July 13, 2011 Report Share Posted July 13, 2011 Hi folks, I want to drag files or folders from Windows explorer into a tree structure of my LabVIEW application. I did not find any solution or example (and I was not able to install the G-Toolbox, which is mentioned in some old forum boards). Does anybody have an example? Thank you very much! Quote Link to comment
Tim_S Posted July 13, 2011 Report Share Posted July 13, 2011 Does anybody have an example? Thank you very much! Have you tried the "Drag and Drop - Multiple Data Types to Start Drag" example? (Ships with LabVIEW) Tim Quote Link to comment
Norm Kirchner Posted July 27, 2011 Report Share Posted July 27, 2011 If memory serves correct, the only control type you can drop into, from windows, into a running front panel, is a path control. I have heard stories and done a quick POC that will allow you to use an invisible path control brought up in front of the thing you want to drop into, catch the drop into the path, then modify the thing that you wanted to have effected by the drop. So it's a little hook and crook, but I know it's been done in a variety of very well done front panels. I think the guys @ JKI do that w/ VIPM ~,~ The Captain Quote Link to comment
Olivier Jourdan Posted July 28, 2011 Report Share Posted July 28, 2011 I agree with Norm, you can do as he describes. I've already done this with a picture container (You can find a demo here https://decibel.ni.com/content/docs/DOC-12914 Note that the purpose of the demo is not the drag&drop...). This is also implemented in tree control in this application http://www.saphir.fr/GB/products/software/Topaze.html fully developed in LabVIEW. Finally, you have to note that it doesn't work with directory. You can just drag file from explorer... Regards, Olivier Quote Link to comment
Popular Post Saverio Posted July 29, 2011 Popular Post Report Share Posted July 29, 2011 Olivier, FYI: your second link point to a non-existent page. It appears you have an extra "s" at the end of "software" You can handle drag and drop by using the Windows API. As a quick way to get started I modified the example that comes with the Windows Message Queue library which you can download from NI. The primary reason for this is that it has a message loop. You can then tell Windows that you're going to accept drag and drop, and register for the WM_DROPFILES message. The DragQueryFile function will tell you how many files were in the drag, and you can then call it repeatedly to get each filename. Attached is the modified example (LV2009) to get you started. You will need to download the library separately from the NI site. All it does is display the dragged files to an array indicator. I also do not check to see where the drop actually occurred (i.e. to see if the user let go of the mouse on the tree control as opposed to somewhere else). If you need this I'll leave it to you to add it in. Windows Drag Drop Example.vi 4 Quote Link to comment
Olivier Jourdan Posted August 8, 2011 Report Share Posted August 8, 2011 Saverio Bad link is Ok now. Thank you for the warning Thank you for sharing your solution. I have to notice that if it allows much more option, it's not cross-platform and can be difficult to maintain over the year Regards, Olivier Quote Link to comment
sparti Posted August 8, 2011 Author Report Share Posted August 8, 2011 Thank you all for your replies. Norm: this could be a solution - but it is really a hook and crook. Oliver: Nice thing but it doesn't work for folders and multiple items. Saverio: Cool thing! This is exactly that what I need. Quote Link to comment
Saverio Posted August 8, 2011 Report Share Posted August 8, 2011 Saverio Thank you for sharing your solution. I have to notice that if it allows much more option, it's not cross-platform and can be difficult to maintain over the year I agree that it's not cross-platform. Unfortunately, a cross-platform solution would need to be implemented by NI directly in LabVIEW. Until then, we're sort of limited to the tools we have at our disposal. Quote Link to comment
Ytochigi Posted March 17, 2016 Report Share Posted March 17, 2016 Saverio, Your solution is very nice. We are looking for a workaround to implement the feature. I'll create Japanese document for this workaround in NI web. Thanks, Yusuke NIJ AE Quote Link to comment
QFang Posted August 16, 2016 Report Share Posted August 16, 2016 On 7/29/2011 at 1:48 PM, Saverio said: Olivier, FYI: your second link point to a non-existent page. It appears you have an extra "s" at the end of "software" You can handle drag and drop by using the Windows API. As a quick way to get started I modified the example that comes with the Windows Message Queue library which you can download from NI. The primary reason for this is that it has a message loop. You can then tell Windows that you're going to accept drag and drop, and register for the WM_DROPFILES message. The DragQueryFile function will tell you how many files were in the drag, and you can then call it repeatedly to get each filename. Attached is the modified example (LV2009) to get you started. You will need to download the library separately from the NI site. All it does is display the dragged files to an array indicator. I also do not check to see where the drop actually occurred (i.e. to see if the user let go of the mouse on the tree control as opposed to somewhere else). If you need this I'll leave it to you to add it in. Windows Drag Drop Example.vi Is this still the 'best' way to do this? NI claims that the functionality of the "Windows Message Queue library" has been superseded by VI Server, but if it has, I'm blind as to how exactly it has? I'm a bit perplexed as I figured adding support for drag-dropping files from explorer into e.g. a graph indicator was as simple as handling the drag-drop event for a given control element, yet, when I created such an event, I found that dragging (a file) from explorer to the graph or chart indicator resulted in the mouse-cursor changing to the 'not allowed' traffic sign, and the drop event never fired..? What I expected to be a few minutes of adding an event handler to look at 'what' was dropped on the graph indicator/control has turned into a wild goose chase online. This cannot still be this hard to do in LabVIEW (2015 SP1)... Or can it? Quote Link to comment
hooovahh Posted August 22, 2016 Report Share Posted August 22, 2016 The "easy" solution as far as I know is the one already described, where you can place a transparent path control on top of your graph and set it to visible when your VI is not active (or mouse leaves the window, I'm not quite sure what works best). Then when you drop a file from explorer it will be dropped on the transparent path control, which generates the Value Change event, and from there you can get the path of the file dropped. It is not ideal, and if there isn't an idea on the Idea Exchange for this to be improved yet, I suggest making one, I'd vote for it. I wouldn't recommend using the Windows Queue API. With the advent of x64 versions of Windows several of those functions don't work, or will work most of the time, but won't work some times. Quote Link to comment
Steen Schmidt Posted January 10, 2017 Report Share Posted January 10, 2017 Probably won't get added to LabVIEW: http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Add-drag-and-drop-support-for-OS-files-on-any-control/idi-p/1073586 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.