Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   VirtualStringTree Drag n Drop vom Explorer frühzeitig erkennen (https://www.delphipraxis.net/204524-virtualstringtree-drag-n-drop-vom-explorer-fruehzeitig-erkennen.html)

DieDolly 3. Jun 2020 17:20

VirtualStringTree Drag n Drop vom Explorer frühzeitig erkennen
 
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.

API 3. Jun 2020 19:09

AW: VirtualStringTree Drag n Drop vom Explorer frühzeitig erkennen
 
Hier solltest du fündig werden.

DieDolly 3. Jun 2020 19:57

AW: VirtualStringTree Drag n Drop vom Explorer frühzeitig erkennen
 
Die Version aus 44 funktioniert für meine Zwecke https://www.delphipraxis.net/679069-post44.html
Für jedes Form einzeln einstellbar, keine globale Procedur mehr die alles abarbeiten muss.

Ein bisschen "Müll" aus der Demo raus, dann funktioniert es wunderbar.
Ansonsten besser als alles was man sonst so findet!

Delphi-Quellcode:
procedure TForm1.ShellDropper1DragEnter(Sender: TObject; const DropRec: TDropRec; var Accept: Boolean);
begin
 Caption := 'DRAG ENTER';
end;

procedure TForm1.ShellDropper1DragLeave(Sender: TObject);
begin
 Caption := 'DRAG LEAVE';
end;

procedure TForm1.ShellDropper1Drop(Sender: TObject; const DropRec: TDropRec);
begin
 if TWinControl(Sender) = ListBox1 then
  ListBox1.Items.Assign(DropRec.Files)
 else if TWinControl(Sender) = Edit1 then
  Edit1.Text := DropRec.Files.Text;

 Caption := 'DRAG DROP';
end;

DieDolly 4. Jun 2020 00:03

AW: VirtualStringTree Drag n Drop vom Explorer frühzeitig erkennen
 
Ich habe gerade bemerkt, dass die Komponente nicht mehr funktioniert, wenn man ein Edit in eine GroupBox oder sonst was packt und das auf einem PageControl mit TabStop True.
Schade. Das wäre die perfekte Lösung gewesen. Ich versuche da mal einen Weg drumherum zu finden. Leider brauche ich das TabStop.

Aber noch eine ganz andere Sache: man kann auch mit dieser Komponente nichts aufs das VST ziehen.
Jede Komponente funktioniert, nur das VST nicht. Egal welchen Drag-Mode man einstellt.


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:55 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz