| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- unit Main;
- interface
- uses
- DragDrop,
- DropTarget,
- DragDropFile,
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, ComCtrls, ExtCtrls;
- type
- TForm1 = class(TForm)
- Panel1: TPanel;
- Label1: TLabel;
- Panel2: TPanel;
- ButtonClose: TButton;
- DropFileTarget1: TDropFileTarget;
- ListView1: TListView;
- procedure ButtonCloseClick(Sender: TObject);
- procedure DropFileTarget1Drop(Sender: TObject; ShiftState: TShiftState;
- Point: TPoint; var Effect: Integer);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.DFM}
- procedure TForm1.ButtonCloseClick(Sender: TObject);
- begin
- Close;
- end;
- procedure TForm1.DropFileTarget1Drop(Sender: TObject;
- ShiftState: TShiftState; Point: TPoint; var Effect: Integer);
- var
- i: integer;
- NewItem: TListItem;
- begin
- // The OnDrop event handler is called when the user drags files and drops them
- // onto your application.
- Listview1.Items.Clear;
- // Copy the file names from the DropTarget component into the list view.
- for i := 0 to DropFileTarget1.Files.Count-1 do
- begin
- NewItem := Listview1.Items.Add;
- NewItem.Caption := DropFileTarget1.Files[i];
- end;
- end;
- end.
|