Is the way to drop the file to the gadget ?

Hi, I'm developing the Vista Sidebar Gadget.

I wonder it is possible that user drag the file on the desktop and drop that file to the gadget.

I may develop that by creating the ActiveX control and instantiating that in the gadget.

In other way, can i develop such a behavior



Answer this question

Is the way to drop the file to the gadget ?

  • edukulla

    You can definitely do this. Check into the API reference on MSDN.
  • shah_hs

    To catch a drag/drop on the Gadget, you need the following code:

    gadget.html. Note you must cancel the "ondragenter" and "ondragover" events.

    ...
    <BODY ondragenter=event.returnValue = false"
    ondragover=event.returnValue = false"
    ondrop="fileDragDropped">
    ...



    And the JS. Note the try/catch - the only way to tell if you've reached the last file, is the error generated when you try to get too many:

    function fileDragDropped() {
    var sFile;
    var i=0;

    try{
    while(System.Shell.itemFromFileDrop(event.dataTransfer, i).path)
    {
    sFile = System.Shell.itemFromFileDrop(event.dataTransfer, i).path;

    // Do something with the file

    i++;
    }
    } catch(err) {}
    }

  • Is the way to drop the file to the gadget ?