System.Shell.itemFromFileDrop Method
Retrieves an System.Shell.Item from the Items collection that represents the object(s) dropped on a gadget during a drag-and-drop operation (copying or moving).
Syntax
oItem = System.Shell.itemFromFileDrop(
oEvent,
intIndex
)
Parameters
- oEvent [in]
object Sets object that specifies the event.dataTransfer object. - intIndex [in]
Int Sets Integer that specifies the index of the System.Shell.Item of interest in the Items collection. - oItem [out]
scr Sets System.Shell.Item object that represents the specified item, or null if the item cannot be determined.
Return Value
HRESULT
If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
To enable listening for the drag and drop event, both ondragenter
and ondragover
events must be disabled in the <body>
tag of the gadget HTML file (see example).
Examples
The following example demonstrates how to display the names of files dropped on the gadget.
<!-- Gadget HTML file. -->
<body onload="Init();"
ondragenter="event.returnValue = false"
ondragover="event.returnValue = false"
ondrop="GetItemFromDrop()">
<div id="gadgetContent">
<span id="spFeedback">Nothing to report.</span>
</div>
</body>
</html>
<!-- Gadget script file. -->
// --------------------------------------------------------------------
// Display the names of objects dropped on the gadget.
// --------------------------------------------------------------------
function GetItemFromDrop()
{
spFeedback.innerHTML = "File(s) dropped.<br/>";
var intIndex = 0;
var oItem;
while(oItem = System.Shell.itemFromFileDrop(event.dataTransfer, intIndex))
{
// Display the current item property and increment the index.
spFeedback.innerHTML += oItem.name + "<br/>";
intIndex++;
}
}
Requirements
Minimum supported client | Windows Vista |
Minimum supported server | Windows Server 2008 |
IDL | Sidebar.idl |
DLL | Sidebar.Exe version 1.00 or later |
See Also
Send comments about this topic to Microsoft
Build date: 2/24/2010
Build type: SDK