Einzelnen Beitrag anzeigen

Dezipaitor

Registriert seit: 14. Apr 2003
Ort: Stuttgart
1.701 Beiträge
 
Delphi 7 Professional
 
#10

Re: Empfänger bei WM_DROPPFILES unterscheiden

  Alt 5. Mär 2010, 23:11
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).
Christian
Windows, Tokens, Access Control List, Dateisicherheit, Desktop, Vista Elevation?
Goto: JEDI API LIB & Windows Security Code Library (JWSCL)
  Mit Zitat antworten Zitat