Main.pas 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. unit Main;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5. StdCtrls, ExtCtrls, DragDrop, DropTarget, DragDropText;
  6. type
  7. TFormMain = class(TForm)
  8. DropTextTarget1: TDropTextTarget;
  9. DataFormatAdapterFile: TDataFormatAdapter;
  10. DataFormatAdapterURL: TDataFormatAdapter;
  11. Panel1: TPanel;
  12. Label1: TLabel;
  13. GroupBox1: TGroupBox;
  14. GroupBox2: TGroupBox;
  15. GroupBox3: TGroupBox;
  16. MemoText: TMemo;
  17. MemoFile: TMemo;
  18. MemoURL: TMemo;
  19. Panel2: TPanel;
  20. procedure DropTextTarget1Drop(Sender: TObject; ShiftState: TShiftState;
  21. Point: TPoint; var Effect: Integer);
  22. private
  23. { Private declarations }
  24. public
  25. { Public declarations }
  26. end;
  27. var
  28. FormMain: TFormMain;
  29. implementation
  30. {$R *.DFM}
  31. uses
  32. // Note: In order to get the File and URL data format support linked into the
  33. // application, we have to include the appropiate units in the uses clause.
  34. // If you forget to do this, you will get a run time error.
  35. // The DragDropFile unit contains the TFileDataFormat class and the
  36. // DragDropInternet unit contains the TURLDataFormat class.
  37. DragDropFormats,
  38. DragDropInternet,
  39. DragDropFile;
  40. procedure TFormMain.DropTextTarget1Drop(Sender: TObject;
  41. ShiftState: TShiftState; Point: TPoint; var Effect: Integer);
  42. begin
  43. MemoText.Lines.Text := DropTextTarget1.Text;
  44. // Check if we have a data format and if so...
  45. if (DataFormatAdapterFile.DataFormat <> nil) then
  46. // ...Extract the dropped data from it.
  47. MemoFile.Lines.Assign((DataFormatAdapterFile.DataFormat as TFileDataFormat).Files);
  48. if (DataFormatAdapterURL.DataFormat <> nil) then
  49. MemoURL.Lines.Text := (DataFormatAdapterURL.DataFormat as TURLDataFormat).URL;
  50. end;
  51. end.