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
BEGIN //
Result := 0;
Exit;
// hier solltest du dann auch die Prozedur verlassen
END;
// sonst bekommst du anschließend eine AV
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;