Main.pas 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. unit Main;
  2. interface
  3. uses
  4. DragDrop,
  5. DropTarget,
  6. DragDropFile,
  7. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  8. StdCtrls, ComCtrls, ExtCtrls;
  9. type
  10. TForm1 = class(TForm)
  11. Panel1: TPanel;
  12. Label1: TLabel;
  13. Panel2: TPanel;
  14. ButtonClose: TButton;
  15. DropFileTarget1: TDropFileTarget;
  16. ListView1: TListView;
  17. procedure ButtonCloseClick(Sender: TObject);
  18. procedure DropFileTarget1Drop(Sender: TObject; ShiftState: TShiftState;
  19. Point: TPoint; var Effect: Integer);
  20. private
  21. { Private declarations }
  22. public
  23. { Public declarations }
  24. end;
  25. var
  26. Form1: TForm1;
  27. implementation
  28. {$R *.DFM}
  29. procedure TForm1.ButtonCloseClick(Sender: TObject);
  30. begin
  31. Close;
  32. end;
  33. procedure TForm1.DropFileTarget1Drop(Sender: TObject;
  34. ShiftState: TShiftState; Point: TPoint; var Effect: Integer);
  35. var
  36. i: integer;
  37. NewItem: TListItem;
  38. begin
  39. // The OnDrop event handler is called when the user drags files and drops them
  40. // onto your application.
  41. Listview1.Items.Clear;
  42. // Copy the file names from the DropTarget component into the list view.
  43. for i := 0 to DropFileTarget1.Files.Count-1 do
  44. begin
  45. NewItem := Listview1.Items.Add;
  46. NewItem.Caption := DropFileTarget1.Files[i];
  47. end;
  48. end;
  49. end.