Autor Beitrag
peicher
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16

Windows XP, Windows 2K, Suse Linux 8.2
Borland Delphi 7
BeitragVerfasst: Di 23.09.03 12:57 
Hallo!
hab folgendes Problem: In meiner Anwendung ist ein VirtualStringTree enthalten. Wenn ich einen Knoten (RootNode) markiert habe, soll er mit dem button UP and DN nach oben oder unten verschoben werden können.

Ich habe zwar dazu die Methode MoveTo gefunden aber ich bekomme ständig die Fehlermeldung: "Node must already be initialized."

Mein Code dazu:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TDetailScreenForm.Btn_UPClick(Sender: TObject);
var
  SourceNode, TargetNode: PVirtualNode;
begin
  SourceNode := VSTree.GetNodeData(VSTree.FocusedNode);
  TargetNode := VSTree.GetNodeData(VStree.GetPrevious(SourceNode));

  VSTree.MoveTo(SourceNode, TargetNode, amInsertBefore, false);
end;


Ich hoffe, dass mir so schnell wie möglich jemand weiterhelfen kann, da diese Funktion für mein Projekt sehr wichtig ist. :oops: :!:

MfG

_________________
-PHIL-
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: Di 23.09.03 14:01 
hast du mal überprüft, ob der targetnode schon existiert? Den ersten knoten kann man schließlich schlkecht nach oben bewegen.

Gruß
KEn

_________________
Eine Klasse beschreibt die Struktur und das Verhalten einer Menge gleichartiger Objekte.
peicher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16

Windows XP, Windows 2K, Suse Linux 8.2
Borland Delphi 7
BeitragVerfasst: Di 23.09.03 14:13 
Ich weis ja, dass des target existiert. es ist ja ganz normal im tree drin. finde das echt seltsam.
die fehlermeldung sagt mir, dass das node erst initialisiert werden muss. was soll ich damit anfangen?

mfg

_________________
-PHIL-
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 24.09.03 07:11 
In welcher Zeile kommt der Fehler? Bereits bei GetNodeData oder erst bei MoveTo?

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
peicher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16

Windows XP, Windows 2K, Suse Linux 8.2
Borland Delphi 7
BeitragVerfasst: Mi 24.09.03 07:17 
Der Fehler kommt schon bei GetNodeData:

ausblenden Delphi-Quelltext
1:
TargetNode := VSTree.GetNodeData(VStree.GetPrevious(SourceNode));					

Hier um genau zu sein.

_________________
-PHIL-
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 24.09.03 08:00 
Gibt GetPrevious eine gültige Referenz auf eine Node zurück oder nil?

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: Mi 24.09.03 09:27 
hallo,

jetzt habe ich mir den kram doch glatt nochmal näher angeschaut. Ich bin mir nicht sicher, ob du NodeData verschieben willst. Deine Prozedur sieht so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TDetailScreenForm.Btn_UPClick(Sender: TObject); 
var 
  SourceNode, TargetNode: PVirtualNode; 
begin 
  SourceNode := VSTree.GetNodeData(VSTree.FocusedNode); 
  TargetNode := VSTree.GetNodeData(VStree.GetPrevious(SourceNode)); 

  VSTree.MoveTo(SourceNode, TargetNode, amInsertBefore, false); 
end;


kann es nicht eher sein, daß du dieses hier machen willst?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TDetailScreenForm.Btn_UPClick(Sender: TObject); 
var 
  SourceNode, TargetNode: PVirtualNode; 
begin 
  SourceNode := VSTree.FocusedNode; 
  TargetNode := VStree.GetPrevious(SourceNode); 

  VSTree.MoveTo(SourceNode, TargetNode, amInsertBefore, false); 
end;
:?:

Gruß
Ken

_________________
Eine Klasse beschreibt die Struktur und das Verhalten einer Menge gleichartiger Objekte.
peicher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16

Windows XP, Windows 2K, Suse Linux 8.2
Borland Delphi 7
BeitragVerfasst: Mi 24.09.03 09:34 
Oh man... Danke @CenBells! Jetzt gehts. Hab davor die ganze Zeit mit GetNodeData gearbeitet und war irgendwie der meinung, dass ich das auch hier verwenden muss.
Jetzt leutets mir ein.

_________________
-PHIL-
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 24.09.03 11:43 
lol... das ich das nicht auch gleich gesehn hab...! :oops:

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!