Recent

Author Topic: VirtualTreeView Double Icons  (Read 2954 times)

lunaticedit

  • Newbie
  • Posts: 2
VirtualTreeView Double Icons
« on: December 16, 2014, 12:15:58 am »
I'm sure I'm doing something horribly wrong as my child node has two icons drawn ontop of each other...

I have set the initial root node and set it's data to point to my singleton. I use an interface to define a node on the tree. The following is in the code that adds the root node:
Code: [Select]
vstProjectExplorer.AddChild(nil, Pointer(IProjectTreeNode(FProject)))
Then I implement reset and init node events like so:
Code: [Select]
procedure TfrmMain.vstProjectExplorerInitNode(Sender: TBaseVirtualTree;
  ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
var
  ptNode: IProjectTreeNode;
  n : PVirtualNode;
  i : Integer;
begin
  ptNode := IProjectTreeNode(Sender.GetNodeData(Node)^);
  Sender.DeleteChildren(Node, False);
  for i := 0 to ptNode.GetNodeChildrenCount - 1 do
  begin
    Sender.AddChild(Node, Pointer(ptNode.GetNodeChild(i)));
  end;

end;

procedure TfrmMain.vstProjectExplorerResetNode(Sender: TBaseVirtualTree;
  Node: PVirtualNode);
var
  ptNode: IProjectTreeNode;
begin
  ptNode := IProjectTreeNode(Sender.GetNodeData(Node)^);
  Sender.ChildCount[Node] := ptNode.GetNodeChildrenCount;
end;

And to update the tree when a project is loaded I do this:
Code: [Select]
      vstProjectExplorer.BeginUpdate;
      vstProjectExplorer.ReinitNode(vstProjectExplorer.RootNode, True);
      vstProjectExplorer.EndUpdate;
      vstProjectExplorer.Refresh;

And finally, here is the interface itself:
Code: [Select]
const

IID_PROJECTTREENODE : TGuid = '{0AC71B6A-E552-4CA6-ADE4-F89304821180}';

type

IProjectTreeNode = interface
  [IID_PROJECTTREENODE]
    function GetNodeTitle: String;
    function GetNodeImageIndex: Integer;
    function GetNodeChildrenCount: Integer;
    function GetNodeChild(Index: Integer): IProjectTreeNode;
    function GetNodeAutoExpand: Boolean;
end;

Getting the image index and text are done pretty much the same (I just cut the code out of the events and put tem next to each other here):
Code: [Select]
CellText := IProjectTreeNode(Sender.GetNodeData(Node)^).GetNodeTitle;
ImageIndex := IProjectTreeNode(Sender.GetNodeData(Node)^).GetNodeImageIndex;

It ~seems~ to work, but it shows the two images ontop of each other as noted in the attached image. Am I doing it all wrong, or is it something simple/obvious.

lunaticedit

  • Newbie
  • Posts: 2
Re: VirtualTreeView Double Icons
« Reply #1 on: December 16, 2014, 01:08:08 am »
Apparently clearing the "Images" property and setting my imagelist to the "StateImages" property 'fixed' it... weird..

 

TinyPortal © 2005-2018