...

View Full Version : Tip: Drag & Drop Files into I.E. (JScript/OLE)



swmr
04-15-2004, 01:40 AM
Something I've wanted to figure out for a while... perhaps you have too. ;)

The Windows common controls include a VBDataObject interface that can be utilized during drag|drop events (as an argument).
Retrieving the path of files dropped onto a control is as simple as checking the format of the Data Object for vbCFFIles (constant = 15), and if true, enumerating the Files collection (1-based) for each item (which returns the full path as a string).

The Animation Control is simplest one I've found for demonstrating this:
Some information about that control is here... (http://msdn.microsoft.com/library/devprods/vs6/vbasic/vbcon98/vbconusinganimationcontrol.htm)



<html>
<head>
<title>IVBDataObject Demo</title>

<style type="text/css">
fieldset{
text-align:center;
padding:2em
}
object{
width:3em;height:3em;
border:6px double activecaption;
vertical-align:middle
}
textarea{
width:60%;margin-top:1em;
word-wrap:normal;
vertical-align:middle
}
</style>

</head>
<body>

<fieldset>
<legend><strong>Drop File(s) </strong>

<object id="IAnimation"
classid="clsid:B09DE715-87C1-11D1-8BE3-0000F8754DA1">
<param name="OleDropMode" value="1">
</object>

&nbsp;</legend>
<label><em>output: </em></label>
<textarea id="output" cols="100" rows="10"></textarea>
</fieldset>


<script type="text/JScript">

function IAnimation::OLEDragDrop(Data){
if(Data.GetFormat(15)){
var O = "";
var e = new Enumerator(Data.Files);
while(!e.atEnd()){
O += e.item() + "\n";
e.moveNext();
}
output.value = O;
BackColor=0x80000003;}
}


// Just for visual feedback...

function IAnimation::OLEDragOver(Data, _, _, _, _, _, State){
if (State == 0){
if(Data.GetFormat(15)){Backcolor = 0x80000002;}
}
if(State == 1){Backcolor = 0x80000003;}
}

function window::onload(){
IAnimation.BackColor=0x80000003;
}
</script>
</body>
</html>


Probably most useful in HTAs, when scripting the FileSystem or Shell objects...

PaulR90
06-23-2005, 07:02 PM
This works as I expect when I left-click drag a file from most folders. The full paths of the dragged files show up in the text box but the files remain unchanged.

:eek: When I drag files from D:\Documents and Settings\Paul\Local Settings\Temporary Internet Files, the full paths still show up, but the files are DELETED. :eek: View refresh does not see them.

Is this expected behavior? I certainly didn't expect it.

My system is WXP SP1 1Gb memory, 1700Mhz Celeron. AOL's McAffee viruscan updates and runs daily, with no reported problems.

enumerator
06-23-2005, 09:34 PM
It works when dragging files from that folder's "Content.IE5" subdirectory (where the data is stored). It fails from "Temporary Internet Files" because these just point into the cache (Content.IE5). The Windows Shell can handle the temp files, so you can either drag them into the filesystem first, or search the underlying cache for the actual files and drag those onto the control.

PaulR90
06-23-2005, 10:27 PM
Thanks for the quick reply. I needed to know that it wasn't a problem unique to my computer. Do you think any other 'special folders' are similarly affected?

enumerator
06-23-2005, 10:58 PM
maybe...

johnnycoder252
06-18-2006, 11:23 PM
How can I save the file to my server. I tried using Data.GetData() but I'm not sure what kind of type I have to pass in as a parameter. The files being dragged on are image files.

dish network
06-08-2010, 07:19 AM
TO swmr: Yes you are right i have been wanting ti figure that our too and I thank you for this very informative and very educational post you have done, I am looking forward to see more of your informative sites.

زواج
06-09-2010, 06:00 AM
I have book marked this page for the future purposes. I have some queries about the topic but I'll just email this to the writer because I want it to be personal.. Thanks for the post :) until next time.

edgars apalais
06-10-2010, 07:22 AM
I found this link on the net after I read the file I tried everything that you have shared.. this is the link and I hope that it will help you on your project **http://www.webreference.com/programming/javascript/mk/column2/**. This is a video tutorial about the Drag and Drop of Javascript.. i am new in the field that is why I am not sure if this will help you.

Darren_Tinsley
06-11-2010, 10:30 AM
I found this link on the net after I read the file I tried everything that you have shared.. this is the link and I hope that it will help you on your project **http://www.webreference.com/programming/javascript/mk/column2/**. This is a video tutorial about the Drag and Drop of Javascript.. i am new in the field that is why I am not sure if this will help you.

Hmm, I've tried to check the video tutorial that you were actually referring too, but no offense, but it seems to be a bit vague for the subject. But still, thanks for your effort edgar

M2 Bodrum
06-12-2010, 06:46 AM
I agree with what you have said and I thank you for sharing this very innovative and insightful information.. :) but I still have questions about your post, can I just send an email for my questions.

Roman_Gertz
06-12-2010, 02:26 PM
Do you mind if the copy the script and edit it a bit? I'd like to try a few workarounds and keep you updated about what would actually happen..

sonnyharrison1
04-04-2011, 05:20 PM
smr for some reason the code I copied did not implement well in my site.
Any feedback?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum