Ich habe es mal korrigiert. So sollte es funktionieren:
Delphi-Quellcode:
function TForm1.IsDropPointInside(const aDropPoint: TPoint; const aControl: TControl): Boolean;
begin
Result := PtInRect(aControl.ClientRect, aControl.ScreenToClient(aDropPoint));
end;
procedure TForm1.AppMessage(var Msg: Tmsg; var Handled: Boolean);
const
BufferLength: word = 255;
var
DroppedFilename: string;
FileIndex: Word;
QtyDroppedFiles: Word;
pDroppedFilename: array[0..255] of Char;
DropPoint: TPoint;
begin
if Msg.Message = WM_DROPFILES then
begin
FileIndex := $FFFF;
QtyDroppedFiles := DragQueryFile(Msg.WParam, FileIndex, pDroppedFilename, BufferLength);
for FileIndex := 0 to (QtyDroppedFiles - 1) do
begin
DragQueryFile(Msg.WParam, FileIndex, pDroppedFilename, BufferLength);
DroppedFilename := StrPas(pDroppedFilename);
//DragQueryPoint(Msg.WParam, DropPoint);
DropPoint := Msg.pt;
if IsDropPointInside(DropPoint, edtCarrierFile) then
edtCarrierFile.Text := DroppedFilename
else if IsDropPointInside(DropPoint, edtTrailerFile) then
edtTrailerFile.Text := DroppedFilename;
end;
DragFinish(Msg.WParam);
Handled := true;
end;
end;
Das Problem war eigentlich, dass DragQueryPoint die Clientkoordinaten des Ziels zurückgibt. In Msg.hwnd ist das
Handle des Ziels (hier das Edit).