





















lazarus编写的程序通过procedure FormDropFiles(Sender: TObject; const FileNames: array of string)可以实现拖放文件,以下是简单的demo,这个demo在linux也没问题。
unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls; type { TForm1 } TForm1 = class(TForm) Memo1: TMemo; procedure FormDropFiles(Sender: TObject; const FileNames: array of string); private public end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of string ); var SName: string; i: integer; begin //MS WordPad, Notepad++ - they get focus on drag-drop from Explorer Application.BringToFront; for i:= 0 to Length(FileNames)-1 do begin if Application.Terminated then exit; SName:= FileNames[i]; if FileExists(SName) then Memo1.Lines.LoadFromFile(SName); Application.ProcessMessages; end; end; end.

此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。