uses ShellAPI;
private
procedure WMDropFiles(var msg: TWMDropFiles); message WM_DROPFILES;
---------------------------------------------------------------------------
procedure TForm1.FormCreate(Sender: TObject);
begin
DragAcceptFiles(Handle, True);
end;
procedure TForm1.WMDropFiles(var msg: TWMDropFiles);
var
compo: TComponent;
Pt: TPoint;
begin
GetCursorPos(Pt);
compo :=FindDragTarget(Pt, True);
if compo <> nil then
ShowMessage(compo.Name + 'にドロップされました。');
//if compo is TPanel then というように
//コンポーネント名で処理を分けることも可能
end; |