Советы по Delphi

Drag & Drop c Win95 Explorer I


Вот что я почерпнул из эхоконференций:

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,Dialogs,
ComCtrls;
type
TForm1 = class(TForm)procedure FormCreate(Sender: TObject);private{ Private declarations }PROCEDURE FileIsDropped ( VAR Msg : TMessage ) ; Message WM_DropFiles ;public{ Public declarations }end;
var
Form1: TForm1;
implementation
uses
shellapi;
{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
DragAcceptFiles( Handle,True ) ;end;

PROCEDURE TForm1.FileIsDropped ( VAR Msg : TMessage ) ;
VAR
hDrop : THandle ;fName : ARRAY[0..254] OF CHAR ;NumberOfFiles : INTEGER ;fCounter : INTEGER ;Names : STRING ;BEGIN
hDrop := Msg.WParam ;NumberOfFiles := DragQueryFile(hDrop,-1,fName,254);Names := '' ;FOR fCounter := 1 TO NumberOfFiles DO BEGINDragQueryFile(hDrop,fCounter,fName,254);// Здесь вы получаете один к одному имя вашего файла
Names := Names + #13#10 + fName ;END ;
ShowMessage('Бросаем '+IntToStr(NumberOfFiles) + ' файла(ов) : ' + Names );DragFinish ( hDrop);END ;

end.

[000089]



Содержание раздела