Hallo,
erst einmal danke für die Tipps. Habe eine Lösung für mein Problem
gefunden. Hier der Code:
Delphi-Quellcode:
type
TItemType = (itRoot, itFolder, itItem);
type
PCodeData = ^TCodeData;
TCodeData = record
Caption: string;
Text: string;
ItemType: TItemType;
OpenIndex: Integer;
CloseIndex: Integer;
end;
...
//------------------------------------------------------------------------------
// Procedure : tvCodeCompareNodes
//------------------------------------------------------------------------------
procedure TCodeForm.tvCodeCompareNodes(Sender: TBaseVirtualTree; Node1,
Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
var
Data1: PCodeData;
Data2: PCodeData;
begin
Data1 := tvCode.GetNodeData(Node1);
Data2 := tvCode.GetNodeData(Node2);
if (not Assigned(Data1)) or (not Assigned(Data2)) then
Result := 0;
if (Data1.ItemType = itFolder) and (Data2.ItemType = itFolder) then
Result := CompareText(Data1.Caption, Data2.Caption);
if (Data1.ItemType = itItem) and (Data2.ItemType = itItem) then
Result := CompareText(Data1.Caption, Data2.Caption);
if (Data1.ItemType = itFolder) and (Data2.ItemType = itItem) then
Result := -1;
if (Data1.ItemType = itItem) and (Data2.ItemType = itFolder) then
Result := 1;
end;
gruss Andreas
Bei schwierigen Problemen entscheiden wir uns einfach für die richtige Lösung.