home *** CD-ROM | disk | FTP | other *** search
- unit Ddmemo;
-
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, FileCtrl;
-
- type
- TMemoForm = class(TForm)
- Memo1: TMemo;
- procedure Memo1DragDrop(Sender, Source: TObject; X, Y: Integer);
- procedure Memo1DragOver(Sender, Source: TObject; X, Y: Integer;
- State: TDragState; var Accept: Boolean);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- MemoForm: TMemoForm;
-
- implementation
-
- {$R *.DFM}
-
- procedure TMemoForm.Memo1DragDrop(Sender, Source: TObject; X, Y: Integer);
- { Check that the Source of the drag operation is a File List Box. If so,
- load the contents of that file into the memo }
- var
- filename : string;
- begin
- if Source is TFileListBox then
- begin
- filename := (Source as TFileListBox).Items.Strings[
- (Source as TFileListBox).ItemIndex];
- if FileExists(filename) Then
- begin
- Memo1.Lines.LoadFromFile(filename);
- Caption := filename;
- end
- else
- MessageDlg('Sorry. Can''t find the file. '+ filename + '!',
- mtInformation, [mbOK], 0);
- end;
-
- end;
-
- procedure TMemoForm.Memo1DragOver(Sender, Source: TObject; X, Y: Integer;
- State: TDragState; var Accept: Boolean);
- { Accept determines whether the Sender (the target of the drag-drop operation)
- can respond to the Source (the object which initiated the drag-drop operation)
- Accept defaults to false. }
- begin
- Accept := true;
- end;
-
- end.
-