![]() |
TVirtualStringTree Drag&Drop...
Hallo!
Mein Programm ist nun quasi fertig - aber es gibt noch ein Problem. Ich benutzte den TVirtualStringTree, um Dateien zum Explorer zu draggen. Das funktioniert soweit auch ganz gut, aber nicht ganz so, wie ich es mir erhofft habe. Wenn ich Dateien größerer Größe in den Explorer ziehe, kopiert er diese Dateien - währenddessen ist mein Programm aber blockiert, bis alle Dateien kopiert sind. Ich habe vorher schon viel mit den Drag&Drop Komponenten von Angus Johnson / Anders Melander herumexperimentiert, Thread gebaut zum Drag&Drop - leider funktionierte davon nichts, und wenn es funktioniert hat, hatte mein Programm danach dauerhaft eine CPU Auslastung von 99% zur Folge - auch nicht gerade wünschenswert... Darum wollte ich einfach mal Fragen, ob jemand so etwas schon einmal mit dem VirtualTree gemacht hat, oder ob jemand eine Idee hat, wie das funktionieren könnte? :stupid: Dank im Vorraus, Alexander |
Re: TVirtualStringTree Drag&Drop...
Moin Alexander,
Zitat:
![]() Wie und was Du da nun sinnvoll einbauen könntest, kann ich Dir ohne ein wenig Code (z.B. der Execute-Methode) allerdings nicht sagen. |
Re: TVirtualStringTree Drag&Drop...
Hallo.
Also, mein Thread dazu sah so aus (habe auch viel dran rumgepfuscht, aber nix hat geholfen..):
Delphi-Quellcode:
Jetzt benutze ich ja den VirtualStringTree, da habe ich es einfacher, weil der Baum dafür direkt Funktionalität bereitstellt. Einfach in der OnCreateDataObject:
{ Drag & Drop Thread
Copyright (c) 2000, 2001 by E.J.Molendijk This class is a part of: "Drag and Drop Component Suite" ([url]http://www.melander.dk[/url]). Explained: When you create the thread, it will copy the filenames of the specified DropFileSource. These filenames will be used by thread to perform a drag&drop operation. The calling thread continues uninterupted. Usage is very simple: TDragDropThread.Create(DropFileSource1); Drag&Drop Thread info Q139408: [url]http://support.microsoft.com/support/kb/articles/Q139/4/08.asp[/url] } unit DragDropThread; interface uses sysutils,Classes, DropSource, ActiveX, Windows; type TDragDropThread = class(TThread) private { Private declarations } FFiles : String; DropFileSource : TDropFileSource; protected procedure Execute; override; public constructor Create(DropFileSource : TDropFileSource); end; implementation { TDragDropThread } constructor TDragDropThread.Create(DropFileSource : TDropFileSource); begin // Thread will start immediately after creation inherited Create(False); // Copy filenames from supplied DropFileSource FFiles := DropFileSource.Files.Text; // This thread disappeard when it finishes FreeOnTerminate := True; end; procedure TDragDropThread.Execute; var pt : TPoint; hwndAttach : HWND; dwAttachThreadID, dwCurrentThreadID : DWORD; begin // Get handle of window under mouse-cursor GetCursorPos(pt); hwndAttach := WindowFromPoint(pt); Assert(hwndAttach <> 0, 'Unable to find window with drag-object'); // Get thread ID's dwAttachThreadID := GetWindowThreadProcessId(hwndAttach, nil); dwCurrentThreadID := GetCurrentThreadId(); // Attach input queues if necessary if (dwAttachThreadID <> dwCurrentThreadID) then AttachThreadInput(dwAttachThreadID, dwCurrentThreadID, True); // Initialize Ole for this thread OleInitialize(nil); try // create dropsource DropFileSource := TDropFileSource.Create(nil); try DropFileSource.Files.Text := FFiles; // start drag&drop DropFileSource.Execute; finally // cleanup dropsource DropFilesource.Free; end; finally // cleanup Ole OleUninitialize; end; // Restore input queues settings if (dwAttachThreadID <> dwCurrentThreadID) then AttachThreadInput(dwAttachThreadID, dwCurrentThreadID, False); end; end.
Delphi-Quellcode:
procedure TfrmMain.lstFilesSearchCreateDataObject(Sender: TBaseVirtualTree;
out IDataObject: IDataObject); var i: Integer; o_Nodes: TNodeArray; o_Data: PNodeData; o_FileList: TStrings; begin o_Nodes := GetNodes(lstFiles, GETNODES_SEL); o_FileList := TStringList.Create; try if Length(o_Nodes) > 0 then begin for i := 0 to Length(o_Nodes) - 1 do begin o_Data := lstFiles.GetNodeData(o_Nodes[i]); o_FileList.Add(o_Data.o_FileData.s_Dir + o_Data.o_FileData.s_File); end; IDataObject := GetFileListDataObject('', o_FileList); end; finally o_FileList.Free; end; end; |
Re: TVirtualStringTree Drag&Drop...
Moin Alexander,
nachdem ich mir nun mal die Drag&Drop Komponenten heruntergeladen, und angeschaut habe: Welche Version hast Du als Basis genommen? Ich habe die Version 4.0 von Angus Johnson, da die andere HP nicht erreichbar war. (Er stellt aber wohl einen Mirror dafür zur Verfügung, durfte also die gleiche Version sein, wie bei Anders Melander) Allerdings konnte ich nur etwas Ähnliches entdecken. Jetzt habe ich mir mal den Thread erneut durchgelesen, und so wohl endlich begriffen, wo genau das Problem liegt :wall: Bisher hatte ich angenommen, dass Du ein Problem mit dem VST in Verbindung mit den Drag&Drop-Kompos hast... aber Du nimmst ja nur eines von Beiden, und jeder Teil macht Probleme... :oops: Ich will mal sehen, was die Demos der D&D so hergeben, denn beim VST hätte ich so keinen Anhaltspunkt wo man eingreifen könnte. |
Re: TVirtualStringTree Drag&Drop...
Hi!
Hatte es mit Version 3.7 (?) und 4 der Drag&Drop Komponenten versucht. Ich bin nicht weitergekommen :( Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:32 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