AGB  ·  Datenschutz  ·  Impressum  







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

VST zeilen verschieben

Ein Thema von jus · begonnen am 9. Jun 2017
Antwort Antwort
jus

Registriert seit: 22. Jan 2005
343 Beiträge
 
Delphi 2007 Professional
 
#1

VST zeilen verschieben

  Alt 9. Jun 2017, 14:48
Hallo,

ich benutze die Virtual String Tree als Liste und möchte die einzelnen Zeilen per Maus verschieben, sprich selber sortieren. Dazu habe ich einfach die Routinen von VST DragNDrop OLE Demo verwendet.
Im Objektinspektor von der VST habe ich folgende Einstellungen:
DragMode: dmAutomatic
DragType: dtOLE
ClipboardFormats: Virtual Tree Data

Delphi-Quellcode:
procedure TForm1.VSTDragOver(Sender: TBaseVirtualTree;
  Source: TObject; Shift: TShiftState; State: TDragState; Pt: TPoint;
  Mode: TDropMode; var Effect: Integer; var Accept: Boolean);
begin
  if Source=VST then Accept := True;
end;

procedure TForm1.VSTDragDrop(Sender: TBaseVirtualTree;
  Source: TObject; DataObject: IDataObject; Formats: TFormatArray;
  Shift: TShiftState; Pt: TPoint; var Effect: Integer; Mode: TDropMode);
var
  S: string;
  Attachmode: TVTNodeAttachMode;
  Nodes: TNodeArray;
  I: Integer;

//--------------- local function --------------------------------------------

  procedure DetermineEffect;

  // Determine the drop effect to use if the source is a Virtual Treeview.

  begin
    // In the case the source is a Virtual Treeview we know 'move' is the default if dragging within
    // the same tree and copy if dragging to another tree. Set Effect accordingly.
    if Shift = [] then
    begin
      // No modifier key, so use standard action.
      if Source = Sender then
        Effect := DROPEFFECT_MOVE
      else
        Effect := DROPEFFECT_COPY;
    end
    else
    begin
      // A modifier key is pressed, hence use this to determine action.
      if (Shift = [ssAlt]) or (Shift = [ssCtrl, ssAlt]) then
        Effect := DROPEFFECT_LINK
      else
        if Shift = [ssCtrl] then
          Effect := DROPEFFECT_COPY
        else
          Effect := DROPEFFECT_MOVE;
    end;
  end;

  //--------------- end local function ----------------------------------------

begin
  Nodes := nil;

  // Translate the drop position into an node attach mode.
  case Mode of
    dmAbove:
      AttachMode := amInsertBefore;
// dmOnNode:
// AttachMode := amAddChildLast; //<------ hier deaktiviert
    dmBelow:
      AttachMode := amInsertAfter;
  else
    AttachMode := amNowhere;
  end;

  if DataObject = nil then
  begin
    // VCL drag'n drop. Handling this requires detailed knowledge about the sender and its data. This is one reason
    // why it was a bad decision by Borland to implement something own instead using the system's way.
    // In this demo we have two known sources of VCL dd data: Tree2 and LogListBox.
  end
  else
  begin
    // OLE drag'n drop. Perform full processing.

    if Source is TBaseVirtualTree then
    begin
      DetermineEffect;
    end
    else
      if Boolean(Effect and DROPEFFECT_COPY) then
        Effect := DROPEFFECT_COPY
      else
        Effect := DROPEFFECT_MOVE;
    InsertData(Sender as TVirtualStringTree, DataObject, Formats, Effect, AttachMode);
  end;
end;
Und es funktioniert auch.

Aber meine eigentliche Frage wäre optischer Natur, und zwar, eigentlich benötige ich nur die Verschiebefunktion auf gleicher Node-Ebene mit der Maus (siehe Node_verschieben.jpg) und nicht die verschiebe Funktionen in die nächste untergeordnete Ebene (siehe Node_kopieren.jpg). Doch wie kann man bei der VST nur das Verschieben in gleicher Ebene mit der Maus zulassen?

Lg,
jus
Miniaturansicht angehängter Grafiken
node_kopieren.jpg   node_verschieben.jpg  

Geändert von jus ( 9. Jun 2017 um 14:51 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort


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 16:42 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