anchor.diff:  {*   only show items in the selected folder.             *}
   {*********************************************************}
   //TODO: Add to AbbreviaVCL packages
  -//TODO: Tighten up component cooperation
   unit AbComCtrls;
   
   interface
  
positive.code: procedure TAbCustomTreeView.Notification(aComponent: TComponent;
    aOperation: TOperation);
  begin
    inherited Notification(aComponent, aOperation);
    if aOperation = opRemove then begin
      if aComponent = FArchive then begin
        FArchive := nil;
        Items.Clear;
      end;
      if aComponent = FListView then
        FListView := nil;
    end;
  end;
  { -------------------------------------------------------------------------- }
  procedure TAbCustomTreeView.SetArchive(aValue: TAbBaseBrowser);
  begin
    if Assigned(FArchive) then begin
      FArchive.RemoveFreeNotification(Self);
      if SameEvent(FArchive.OnChange, DoChange) then
        if Assigned(ListView) then
          FArchive.OnChange := ListView.DoChange
        else
          FArchive.OnChange := nil;
    end;
    FArchive := aValue;
    if Assigned(FArchive) then begin
      FArchive.FreeNotification(Self);
      FArchive.OnChange := DoChange;
      DoChange(Self);
    end
    else
      Items.Clear;
  end;
  { -------------------------------------------------------------------------- }
  procedure TAbCustomTreeView.SetListView(aValue: TAbCustomListView);
  begin
    if Assigned(FListView) then begin
      FListView.RemoveFreeNotification(Self);
      FListView.TreeView := nil;
    end;
    FListView := aValue;
    if Assigned(FListView) then begin
      FListView.FreeNotification(Self);
      FListView.TreeView := Self;
    end;
  end;
  { -------------------------------------------------------------------------- }
  procedure TAbCustomTreeView.SetPath(const aValue: string);
  var
    Filename, Remaining: string;
    i: Integer;
    Node: TTreeNode;
  begin
    if FPath <> aValue then begin
      FPath := ExcludeTrailingPathDelimiter(aValue);
      // Find selected node, expanding parents along the way
      Node := Items.GetFirstNode;
      Remaining := FPath;
      if StartsText(PathDelim, Remaining) then
        System.Delete(Remaining, 1, 1);
      while Remaining <> '' do begin
        Node.Expand(False);
        i := Pos(PathDelim, Remaining);
        if i = 0 then
          i := Length(Remaining) + 1;
        Filename := Copy(Remaining, 1, i - 1);
        Remaining := Copy(Remaining, i + 1, MaxInt);
        if Filename = '' then
          Continue;
        Node := Node.getFirstChild;
        while (Node <> nil) and not SameText(Filename, Node.Text) do
          Node := Node.getNextSibling;
        if Node = nil then begin
          Node := Items.GetFirstNode;
          Break;
        end;
      end;
      Selected := Node;
      // Update listview
      if Assigned(FListView) then
        FListView.Path := aValue;
    end;
  
negative.code:   protected {properties}
      property HeaderImages : TImageList
        read FHeaderImages;
  
    public {methods}
      constructor Create(aOwner: TComponent);
  