Jump to content

Window Drag and Drop (bodge)

Recommended Posts

This VI demonstrates how you can bodge a VI to accept drag and drops of files and folders just like a path control (without losing any mouse click/move event functionality).

Path controls have an API for dragging and dropping Files/folders from the OS, or correctly formatted strings from Excel. While an acceptable drag-and-drop operation is underway the path control adds a dotted box to the control (I'm calling this a target box). However this behavior is not available for other objects such as panes or other controls. So Bodging time.

DragandDropBodge.vi (attached to the original lavag.org post) has a transparent Path control (set to 'Scale object with pane') that in all the use cases where a drag and drop is possible is set to Visible=True, and in all the use cases where the user would click on an object within the pane is set to Visible=False. I am using a shift register and the Timeout case to Visible=False the Path control, but for a more complex VI or when you have an existing need for the Timeout Case, you can manage this with a user event.

Other implementations:

This could be used to bodge drag-and-drop for a xy graph or other indicator instead of the pane at large. Or by capturing the cursor position at the moment of 'value update' for the path control a drag and drop could update a specific line in a tree/table/array.


Hope this helps when you are searching with the same keywords I was and found no solutions!



Link to post

Join the conversation

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

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.

  • Similar Content

    • By jmltinc
      Hi Folks,
      I have some popup VIs that can be called by the main VI's menu as well as from the popups themselves. These VIs are not dropped inside any VI, but are called dynamically using their path - either absolute or relative to the caller. My problem is, I do not know where the VIs might be placed at the time of the Build.
      Without going too deeply into the dirty laundry and politics of our company, the project was divided into 2 parts. One part is concerned with retrieving and writing data to a database (my part). This requires user interaction. My contribution is integrated into a legacy application "owned" by another person. That person controls the main VI as well as the Build and distribution. Unfortunately, he operates autonomously and without communication. Bottom line is I have no idea where he will place the VIs for the build and he may change the location at any future build.
      I cannot use the Get VI Dependency method because the popups are called dynamically and therefore do not exist on any block diagram. Is there any way to retrieve these paths within an executable at runtime?
      Yes, I know the answer is to work as a team, but that is not going to happen...
    • By patufet_99
      I have a vi, where after closing the file there is a check if some parameter has changed, so that the filename should be changed accordingly.
      What is done is simply create a new path with the current parameters, and check this path with the original path of the saved file. If both paths are identical, nothing is done. If the paths are different then the file is renamed with the "Move" VI.
      The vi works as expected most of the time, but where the executable is installed by a customer, error 10 is returned occasionally.
      I do not understand how this can happen: if the path is duplicated then the result of the comparison should avoid the file name change.
      In case that another file with the same name already existed, the returned error would then be different.
      Any hints of what could be happening are welcome.
      Thank you.

    • By Houmoller
      Hi lava,
      I hope you can help me with my problem.
      The problem that I want to solve (in a proper way) is the following: 
      I have a list of all the *.dat files in a folder. I want this list to update every time a new *.dat file i created in that folder.
      I don't want to pool the folder constantly so I have solved this problem by using a dynamic event from a .NET action. This is all nice and great.
      My problem is, that if I change the folder, my dynamic event does not execute when a new file is added to the new folder.
      I have attached two snippets of the main part of the code. 
      In the mainVI, I first setup some events. The events are then written to a global variable. It is this global that I use when broadcasting the event.  
      In the watch_dir.VI the .NET event is setup. I look for files that are created, deleted, changed or renamed. (Most of the code is from Steve Chandler's nugget: http://forums.ni.com/t5/LabVIEW/My-First-Nugget-Directory-Changed-Event/m-p/1407552)

      I have tried initializing the different events when the folder is changed,but that does not seem to fix the problem. I hope I have made myself clear, but please dont hesitate in asking questions. 
      I could off course just pool the number of files in the folder or something like that, but that doesn't seem right to me.
      I hope you can help me. 
    • By David_L
      I've been doing some tinkering and can't seem to find a nice solution to this problem. Does anyone know of a way you can select multiple files from a path control? I know this can be done with the File Dialog Express VI, but I'd like to do it more gracefully from the front panel control. I don't think it's possible, but maybe someone here has some neat trick.
      Alternately, is there any way to capture the drag event from multiple files dragged from Windows? I know a single file dragged into a File Path Control will populate it with the correct path, but maybe there's a way to drag multiple files onto an array of paths or something.
  • Create New...

Important Information

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