TDragDropFiles

 
     

 

 

  Description
 
  TDragDropFiles is a comfortable and powerful component for COM/OLE drag&drop operations with files. The component is a child-class from TDragDrop.

IMPORTANT: TDragDropFiles doesn't support shortcuts to files like TDragDropFilesEx.

   
  Important for Use
 
  This file (index.htm) contains more information about restrictions, the disclaimer, remarks etc.
   
  History
 
  Version 3.10 published on 06-Jul-1999
 
  • Code re-design in result of modifications in TDragDrop; handling hasn't changed
  Version 3.01 published on 07-Oct-1998
 
  • small invisible bugs fixed
  Version 3.00 published on 03-Oct-1998
 
  • Total internal redesign due to modifications of the super-class, but the handling hasn't changed
  • component's icon has changed
  •   Version 2.00 published on 06-Aug-1999
     
    • Internal structure was totally re-designed (has now the mother-class TDragDrop), but the handling hasn't changed
      Version 1.03 published on 29-Jun-1998
     
    • A bug was removed (accepting files)
      Version 1.02 published on 10-Jun-1998
     
    • The result of the method ExecuteDragDrop has changed (new result type)
      Version 1.01 published on 03-Feb-1998
     
    • Some properties were added
    • New demo
    • New handling on dwEffect
      Version 1.00 published on 11-Nov-1997
     
    • First official release
       
      Properties
     
      inherited properties
      Click here ...
     
      FileList public
      For Target: Use this stringlist in OnProcessDropped, if you want to get the dropped files.

    For Source: Add the files to the stringlist, which you want to d&d, before calling Execute.

     
      Events
     
      inherited events
      Click here ...
     
      Methods
     
      inherited methods
      Click here ...
     
      Execute public
      Call this method, if you detect that the user wants to start a drag&drop operation (e.g.: MouseDown+MouseMove). Also look: FileList.

    For drag detection you can also use the inherited property AutotDetectDnD or the method StartDnDDetection.

    IMPORTANT: If you use the drag-detection, it's high recommended to check the section "Problems With The Drag-Detection".

     
      How Do I Use It As Drag&Drop Source
     
      1. Drop a TWinControl on the form (e.g. a listbox).
      2. Choose the TWinControl (listbox) in DragDropControl.
      3. Choose the drag&drop effects under SourceEffects which the DragDropControl (listbox) should support. If you don't want any longer that the DragDropControl serve as drag&drop source all items must be set to false.
      4. Now, your DragDropControl (listbox) must detect, when the user wants to start a drag&drop operation. You can use the event "OnMouseDown" of your DragDropControl (listbox). Add following to the event:

    DragDropFiles1.FileList.add(<selected items of the DragDropControl (listbox)>);

    You must add the filenames including the WHOLE PATH!!!

      5. Tell Windows that there is a drag&drop operation to handle: Just call the method Execute of this component.
      6. You may use the events OnGiveFeedback and OnQueryContinueDrag, but often you need not.
         
      Hints:
     
    • Drag&drop operations cannot be done at design-time!
    • IMPORTANT: If you use the drag-detection, it's high recommended to check the section "Problems With The Drag-Detection".
       
      How Do I Use It As Drag&Drop Target
     
      1. Drop a TWinControl on the form (e.g. a listbox).
      2. Choose the TWinControl (listbox) in DragDropControl.
      3. Choose the drag&drop effects under TargetEffects which the DragDropControl (listbox) should support. If you don't want any longer that the DragDropControl serve as drag&drop target all items must be set to false.
      4. Now, you have to program what happen, if the user drops files on your DragDropControl (listbox). For this, the best is to use the event OnProcessDropped. At first, you should check what drag&drop effect was chosen by the user. You get the effect from method's parameter dwEffect. You get the filenames from this component with following line:

    ...:=DragDropFiles1.FileList[<Index>];

    FileList is a stringlist. For more info check the Delphi's online-help. Now, do with the files what you have to do, e.g. copy, move, delete, etc.

      5. You may use the events OnDragEnter, OnDragOver and OnDragLeave, but often you need not.
         
      Hints:
     
    • Drag&drop operations cannot be done at design-time!
       
      FAQ
     
      Q: My application supports only some special file-formats. How can I forbid the other formats during the drop?

    A: Set the property RenderOn to rdoDropEnterAndDropSync and check out the Filelist in the event OnDragEnter. Set the parameter Accept in this event to true, if your application support the files in the Filelist otherwise set the parameter to false. If you only use the first file, check only the first item in the Filelist.

       
      Known Bugs
     
     
    • Shortcuts to desktop or explorer, etc. aren't possible. You must use the component TDragDropFilesEx to have this feature.
       

    © 1998,99 by Dieter Steinwedel

    Back to index