Jump to content
sparti

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!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Saverio

  1. Bad link is Ok now. Thank you for the warning
  2. 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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.