Einzelnen Beitrag anzeigen

DieDolly

Registriert seit: 22. Jun 2018
2.175 Beiträge
 
#1

VirtualStringTree Drag n Drop vom Explorer frühzeitig erkennen

  Alt 3. Jun 2020, 17:20
Weiß jemand zufällig, wie man Dateiem von Explorer in ein VST bekommt?

Hier mein Ansatz und gleich sage ich euch, wo mein Problem ist
Delphi-Quellcode:
DragAcceptFiles(vst.Handle, Accept);

procedure ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
const
 BufferLength = 255;
var
 QtyDroppedFiles, FileIndex: Integer;
 pDroppedFilename: array [0 .. BufferLength] of Char;
begin
 Handled := False;

 case Msg.message of
  WM_DROPFILES:
   begin
    QtyDroppedFiles := DragQueryFile(Msg.WParam, Cardinal(-1), nil, 0);

    try
     for FileIndex := 0 to QtyDroppedFiles - 1 do
      begin
       DragQueryFile(Msg.WParam, FileIndex, @pDroppedFilename, BufferLength);

       DragDropHandleProcess(Msg.HWND, PChar(@pDroppedFilename));
       Break;
      end;
    finally
     DragFinish(Msg.WParam);
     Handled := True;
    end;
   end;
 end;
end;

procedure DragDropHandleProcess(Wnd: HWND; const Path: string);
begin
 showmessage(Path);
end;
Funktioniert! Aber ich muss schon VOR dem "Drop" wissen, woher die Datei kommt. Also während man gerade die Maus drüberbewegt.
Mit welchem Event bekommt man das hin?
Ich weiß, dass es VSTStartDrag gibt. Aber wie finde ich heraus, dass die Eingabe gerade von Außerhalb der Anwendung kommt?

DragType steht auf dtVCL und das muss leider auch so sein.

Geändert von DieDolly ( 3. Jun 2020 um 17:37 Uhr)
  Mit Zitat antworten Zitat