2009-05-16 01:16:38 UTC
Hey all.
I only just found this, after many false starts.
I was getting the same error, so I put my investigating shoes on.
The problem code (at least for 2006) is in
procedure TStCustomShellTreeView.CreateWnd;
Originally it looks like this (only problem code shown):
inherited CreateWnd;
{ If the window has been recreated then the HasChildren property }
{ has been cleared and we need to reset it. }
if RecreatingWnd then begin
Node := Items[0];
while Node <> nil do begin
SI := Folders[Integer(Node.Data)];
if SI <> nil then
if SI.HasSubFolder then
Node.HasChildren := True;
Node := Node.GetNext;
end;
Exit;
end;
{ For cases when the component is being created dynamically. }
<---snip---->
The problem is in the if block. Change it to
if RecreatingWnd then begin
if Items.Count > 0 then begin <-------------------- Add
Node := Items[0];
while Node <> nil do begin
SI := Folders[Integer(Node.Data)];
if SI <> nil then
if SI.HasSubFolder then
Node.HasChildren := True;
Node := Node.GetNext;
end;
end; <----------------------Add
<----------------------Remove Exit;
end;
Adding in the if blcok to test the Items.Count got rid of the error, but it would not fill the control at design time (It still worked at run time).
Removing the exit allows the control to fill when the form is opened in design.
So far it hasn't given me any hiccups.
Kudos to the original developers. Its a luverly piece of code.