lazarus实现拖放文件
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.


浙公网安备 33010602011771号