AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

TVirtualStringTree Drag&Drop...

Ein Thema von wicht · begonnen am 22. Jan 2006 · letzter Beitrag vom 26. Jan 2006
 
Benutzerbild von wicht
wicht

Registriert seit: 15. Jan 2006
Ort: Das schöne Enger nahe Bielefeld
809 Beiträge
 
Delphi XE Professional
 
#3

Re: TVirtualStringTree Drag&Drop...

  Alt 24. Jan 2006, 14:50
Hallo.

Also, mein Thread dazu sah so aus (habe auch viel dran rumgepfuscht, aber nix hat geholfen..):

Delphi-Quellcode:
{ 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.
Jetzt benutze ich ja den VirtualStringTree, da habe ich es einfacher, weil der Baum dafür direkt Funktionalität bereitstellt. Einfach in der OnCreateDataObject:

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;
http://streamwriter.org

"I make hits. Not the public. I tell the DJ’s what to play. Understand?"
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:07 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-2025 by Thomas Breitkreuz