Hot to Drag OUT of a form in vb.net [HERLP]
i'm having this problem in ma head for months till i decided to ask it here (of course i digg every search engine).
The question is simple:
I'm making an app like winzip (an extractor) and i successfully coded dragging a file in and opening. But i now need to drag the files out, like in winzip in which i can drag and drop a file on to any folder directly. But how to implement that into my program?
Re: Hot to Drag OUT of a form in vb.net [HERLP]
i figured it out (cheating really)
and i'll post it here n submit as a tut for future use :D
First i muz tell tat drag out thing can be easily done using the doDragDrop func() but the problem is it always have a custom event. Like just to copy a file which is already EXIST, or move like so.
But most of the time the need is to dodragdrop for a virtual file.
ex: in ma project which is a decompressioner i wanted to get the target path and then decompress the file to that path. Because there's no possible way of to create the file before dragging off!
So i cnt use the normal func as:
(1) As i cannot provide my own codes for that or get the target path
(2) I cannot delay the process to decompress the file
So i found a CHEATING method.
[The original idea is not mine, i saw da idea and just coded it suitably :D )
The idea behind is to add some filesystemwatchers to Watch weather a SPECIFIC file to created and WHERE.
So the theory is i'm going to make a 'fake' file drop (just tel the user and the system that i dropped a file) but instead of dropping the real file i use a predifined file. (with a remarkable ext.)
So when the file is created the fileSystemWatcher FIRES! and tell us the target dir! :D
First we need to setup filesystem wacthers and the form load:
remeber to use your own one as i dont want ma prog go messing around :D
Now the code to say What To Do when we find a drop of that file.
PLEASE note that this action runs on a seperate thread so be creaful not to add actions with cross-thread references.
Now to add the real part, where the file is dragged out
Here i have used a lstView and i coded in the itemDrag.
I just copied the file "tmp_donot_delete.antf2" from the ma prog dir to the target dir.
(NOTE: tmp_donot_delete.antf2 is the file name i've given. You'll need to have this file created evrythime you run your prog. Of corse thats simple and you can add hidden + system attribs to make sure this file is hidden)
So that way, when user drag out the file, tmp_donot_delete.antf2 will copy to the target dir and the FileSystemWatcher will catch it then get the target dir in the output variable. So you can use it on your wish!
I'm sorry for the bad gramer n all mistakes. Please feel free to ask on any matter :D
[Credits goes for the one who really thought of this idea]
Final Notes: This method is not 100% good, but easy to use. If you really need it in the professional way you'll have to extend your searches on shellExts
|All times are GMT +5.5. The time now is 02:33.|