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/)
-   -   Delphi Listbox zu Explorer (https://www.delphipraxis.net/12248-listbox-zu-explorer.html)

Uncle Cracker 23. Nov 2003 21:25


Listbox zu Explorer
 
Mit diesem Code kan man Daten vom Explorer aus in eine Listbox ziehen:

Delphi-Quellcode:
uses
  ShellAPI;

var
  OldLBWindowProc: TWndMethod;

procedure TForm1.AddFile(sFileName: string);
begin
  ListBox1.Items.Add(sFilename);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  OldLBWindowProc := ListBox1.WindowProc;
  ListBox1.WindowProc := LBWindowProc;
  DragAcceptFiles(ListBox1.Handle, True);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  ListBox1.WindowProc := OldLBWindowProc;
  DragAcceptFiles(ListBox1.Handle, False);
end;

procedure TForm1.LBWindowProc(var Message: TMessage);
begin
  if Message.Msg = WM_DROPFILES then
    WMDROPFILES(Message);
  OldLBWindowProc(Message);
end;

procedure TForm1.WMDROPFILES(var Msg: TMessage);
var
  pcFileName: PChar;
  i, iSize, iFileCount: integer;
begin
  pcFileName := '';
  iFileCount := DragQueryFile(Msg.wParam, $FFFFFFFF, pcFileName, 255);
  for i := 0 to iFileCount - 1 do
  begin
    iSize := DragQueryFile(Msg.wParam, i, nil, 0) + 1;
    pcFileName := StrAlloc(iSize);
    DragQueryFile(Msg.wParam, i, pcFileName, iSize);
    if FileExists(pcFileName) then
      AddFile(pcFileName);
    StrDispose(pcFileName);
  end;
  DragFinish(Msg.wParam);
end;
Nun wollte ich fragen ob das irgendwie anderesrum auch möglich wäre?


Vielleicht hat das schon mal jemand gemacht und kann mir helfen.


:love: Danke UC

toms 23. Nov 2003 21:44

Re: Listbox zu Explorer
 
Drag & Drop Component Suite von Anders Melander & Angus Johnson
http://www.users.on.net/johnson/delphi/dragdrop0400.exe

Uncle Cracker 23. Nov 2003 22:35

Re: Listbox zu Explorer
 
:love: Danke dir tom,

aber gibt's vielleicht noch eine Methode ohne Komponente, da ich zusätzliche Komponenten nicht so toll finde.

PS: Außer natürlich die Standard und du Indys-Komponenten :zwinker:

Uncle Cracker 24. Nov 2003 22:46

Re: Listbox zu Explorer
 
Das funktitioniert mit den Komponenten, jedoch würde ich gern das ohne Komponenten machen, denn der Quelltext wird weiter gegeben und da sind Komponenten nicht so sinnvoll.

Vielleicht hat jemand eine Funktion oder Procedure für mich?


:love: Danke UC

toms 24. Nov 2003 23:35

Re: Listbox zu Explorer
 
Zitat:

Vielleicht hat jemand eine Funktion oder Procedure für mich?
Hi, das geht nicht mit einer einzelnen Funktion/Prozedur.
Da sind Ereignisse im Spiel! (Siehe Source Code der Komponente)

Uncle Cracker 24. Nov 2003 23:37

Re: Listbox zu Explorer
 
Achso, ich dachte das geht so einfach wie anderesrum, also wie von Explorer zu Listbox.

Wenn das so ist, dann muss ich wahrscheinlich doch die Komponenten nutzten :|


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:25 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