![]() |
Drag Drop Problem
Hallo,
ich habe ein kleines Problem mit Drag/Drop in eine Listbox. Wenn ich die Listbox direkt auf dem Formular habe, kann ich einen File per drag/drop hinzufügen. Wenn die Listbox aber auf einem Panel liegt funktioniert es leider nicht :( Als Grundlage habe ich den TIP aus ![]() Irgend wie stehe ich auf dem Schlauch warum es nicht funktioniert Gruß Torsten |
Re: Drag Drop Problem
Hallo,
so müsste es gehen:
Delphi-Quellcode:
Du fängst einfach die Nachricht WM_DROPFILES dann von der Listbox ab.
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TListBox = class(StdCtrls.TListBox) private procedure WMDROPFILES(var Msg: TMessage); Message WM_DROPFILES; end; type TForm1 = class(TForm) ListBox1: TListBox; Panel1: TPanel; procedure FormCreate(Sender: TObject); private public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} uses ShellAPI; procedure TListBox.WMDROPFILES(var Msg: TMessage); var i, Counts, Size: Integer; PCharFileName: PChar; begin inherited; PCharFileName := nil; Counts := DragQueryFile(Msg.WParam, $FFFFFFFF, PCharFileName, 255); for i := 0 to Counts - 1 do begin Size := DragQueryFile(Msg.WParam, i, nil, 0) + 1; PCharFileName := StrAlloc(Size); DragQueryFile(Msg.WParam, i, PCharFileName, Size); Items.Add(String(PCharFileName)); StrDispose(PCharFileName); end; DragFinish(Msg.WParam); end; procedure TForm1.FormCreate(Sender: TObject); begin DragAcceptFiles(ListBox1.Handle, True); end; end. EDIT: mit ![]() |
Re: Drag Drop Problem
Danke
noch ein schönes Wochenende Torsten |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:59 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz