Skip to content

Wrong management of Vertical ScrollBar #1304

@shineworld

Description

@shineworld

Hi, I'm using latest version of VT ( 015ebe5 ) and I've noticed that vertical scrollbar
does not works fine when I expand some node, but also when all nodes are expanded and I resize the tree view control.

2025-06-13.08-50-48.mp4

Seems that calculated size of tree is not valid.

At frame create the main root nodes are created:

type
  PTreeData = ^TTreeData;
  TTreeData = record
    UID: TGUID;
  end;

constructor TVMSetupFrame.Create(AOwner: TComponent);

  procedure CreateTreeViewStructure;

    function AddNode(PartType: TMachinePartType): PVirtualNode;
    var
      NodeData: PTreeData;
    begin
      Result := TreeView.AddChild(nil);
      NodeData := TreeView.GetNodeData(Result);
      NodeData.UID := GetVMManager.MachinePartsList.Parts[PartType, 0].PartUID;
    end;

  begin
    TreeView.NodeDataSize := SizeOf(TTreeData);
    FRootNodeF := AddNode(mptp_FixedRoot);
    FRootNodeX := AddNode(mptp_AxisXRoot);
    FRootNodeY := AddNode(mptp_AxisYRoot);
    FRootNodeZ := AddNode(mptp_AxisZRoot);
    FRootNodeM := AddNode(mptp_MasterRoot);
    FRootNodeS := AddNode(mptp_SlaveRoot);
  end;

begin
  // creates tree view structure
  CreateTreeViewStructure;
  ....
  ..
  ....
  // updates tree
  UpdateTree;

  // selects first node
  TreeView.Selected[FRootNodeF] := True;
end;

procedure TVMSetupFrame.UpdateTree;

  procedure UpdateNodes(Parent: PVirtualNode; PartType: TMachinePartType);
  var
    I: Integer;
    C: Integer;
    Child: PVirtualNode;
    NodeData: PTreeData;
  begin
    C := GetVMManager.MachinePartsList.Count[PartType];
    for I := Parent.ChildCount to C - 1 do
      TreeView.AddChild(Parent);
    for I := Parent.ChildCount downto C + 1 do
      TreeView.DeleteNode(Parent.LastChild);
    if Parent.ChildCount > 0 then
    begin
      Child := nil;
      for I := 0 to Parent.ChildCount - 1 do
      begin
        if I = 0 then
          Child := Parent.FirstChild
        else
        begin
          if Child = nil then Exit;
          Child := Child.NextSibling;
        end;
        if Child = nil then Exit;
        NodeData := TreeView.GetNodeData(Child);
        NodeData.UID := GetVMManager.MachinePartsList.Parts[PartType, I].PartUID;
      end;
    end;
  end;

begin
  TreeView.BeginUpdate;
  try
    UpdateNodes(FRootNodeF, mptp_Fixed);
    UpdateNodes(FRootNodeX, mptp_AxisX);
    UpdateNodes(FRootNodeY, mptp_AxisY);
    UpdateNodes(FRootNodeZ, mptp_AxisZ);
    UpdateNodes(FRootNodeM, mptp_Master);
    UpdateNodes(FRootNodeS, mptp_Slave);
  finally
    TreeView.EndUpdate;
  end;
end;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Repro Steps MissingA smple project is needed to reprodcue and analyze the issue. See our guidelines for opening issues!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions