Jump to content

Drop into a tree from other program


Recommended Posts

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!

Link to comment
  • 2 weeks later...

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

Link to comment

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

Link to comment
  • 2 weeks later...

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.

Link to comment

Saverio

  1. 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. :(

Link to comment
  • 4 years later...
  • 4 months later...
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?

Link to comment

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.

Link to comment
  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.