Hello!

Faced such a problem: you need to write a program in which you need to drag the text file to view into the window Memo1, designed to view it, and to select a file you need to use the components DirectoryListBox and FileListBox.

When moving to the field Memo1 should pop up a message that the file has been successfully moved, or vice versa that the file can not be moved.

Actually, two questions.

  1. By what criteria it is possible to designate successful file transfer / impossibility to transfer it to the field?
  2. How to implement the message "File moved / " File cannot be moved " after trying to add a file to the field?
  • one
    How to implement the message "File moved /" File cannot be moved "after trying to add a file to the field? I think the file extension should be checked (disable to jpg, bmp, mp3, etc) - Vfvtnjd
  • Generally it is nonsense. The “dragging” of the source can and should be checked before the start of dragging. - karmadro4

1 answer 1

You can try this:

procedure dragfile(FilePath: string); var MyFile: TextFile; function trytoopen: boolean; begin if Copy(FilePath, Length(FilePath) - 4, Length(FilePath)) = '.txt' then try AssignFile(MyFile, FilePath); result:= true; except result:= False; end; begin ... if trytoopen(FilePath) then begin Reset(MyFile); ShowMessage('Файл перемещен'); end else ShowMessage('Файл переместить нельзя'); ... end;