LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Drag and Drop FileBrowser

I would like to select files from a FileBrowser Tree window (filebrowser.fp) by the Drag -n- Drop method in my GUI. I want to drag a file in the filebrowser, to pull it over a Textbox, and to drop it, so the path and/or the filename appears in the Textbox. I found only one example for 'drag and drop', but it doesnt help, it shows me how to drag-and-drop inside a Tree box, with child items, and so on. (I cannot implement what I saw there due to I am still quite a beginner in LabWin.)
Could somebody give me a short example how to manage this, or a link with an example?
Thank you very much,
best regards,

András B-D.
0 Kudos
Message 1 of 5
(3,502 Views)
Hello Andreas,
 
Some time ago I wrote an example for someone on how to use the EnableDragAndDrop function on a panel, and how to use it. I attached it to this post. If you drag files (e.g. fromWindows Explorer) into the rectangle on the panel, all file names will appear in the table.
Unfortunately you cannot drag files from a FileBrowser Tree window.  So I think you will have to write your own function for this. Here is what I would do:
- In the callback function of your FileBrowser Tree, in case of an EVENT_LEFT_CLICK event, get the selected files.
- Wait until the user releases the mouse button (use GetRelativeMouseState in a while-loop to check this).
- Now check if the mouse cursor is over the Textbox.
To visualize the dragging, you could change the mouse cursor shape.
 
Success,
Wim
0 Kudos
Message 2 of 5
(3,492 Views)
Thank you very much!
Best Regards,

András Bükki-Deme
0 Kudos
Message 3 of 5
(3,489 Views)
Thank you very much!
Best Regards,

András Bükki-Deme
0 Kudos
Message 4 of 5
(3,489 Views)
Hello Andreas,
 
I changed the source code of my example a little bit. I hope this is what you are looking for. Now you can drag files from the filebrowser to a textbox.
There are a few things that might need some explanation. As you will see, I implemented the drag and drop procedure in the callback of the panel, instead of the callback function of the filebrowser itself. There is a good reason for this: When the filebrowser is created, using the FileBrowser_Create function, it splits itself up into two controls. One for the tree and another one (I think it's a table). Because of this, the callback function of the filebrowser is only called when the left part of the filebrowser (the tree-part) is clicked. So what I did in my code is check the panel's callback function and check if the mouse cursor is over the filebrowser. Also, note that I got the filebrowser's bounding rectangle before calling the FileBrowser_Create function. If you call the GetCtrlBoundingRect function afterwards, you would only get the bounding rectangle of the tree-part of your FileBrowser.
 
I hope this helps you a bit further.
Wim

Message Edited by Wim S on 02-06-2007 10:51 AM

0 Kudos
Message 5 of 5
(3,485 Views)