2013/9/12 J?rgen Hestermann
Show quoted text 34 lines
Am 2013-09-12 17:51, schrieb Frederic Da Vitoria:
> My remarks only come from my memories of how VirtualTreeView worked with
Delphi 6.
> The code has obviously much changed since.
Are you sure? The function is quite simple:
------------------------------**------------------------------**---------
function TBaseVirtualTree.**AbsoluteIndex(Node: PVirtualNode) : Cardinal;
begin
Result := 0;
while Assigned(Node) and (NodeFRoot) do
begin
if not (vsInitialized in Node.States) then
InitNode(Node);
if Assigned(Node.PrevSibling) then
begin // if there's a previous sibling then add its total count to
the result
Node := Node.PrevSibling;
Inc(Result, Node.TotalCount);
end
else
begin
Node := Node.Parent;
if NodeFRoot then
Inc(Result);
end;
end;
end;
------------------------------**------------------------------**---------
It's hard to believe that there was a version of VirtualTreeView
that used signed intergers *and* had code to set it to -1 *and*
then someone has changed it to a non-signed integer *and*
also removed or changed the code to now set it to zero.
No, I am not sure, as I stated in my first answer, I am answering from memory, all my answers here are mainly guesses. Either my first assumption is right or maybe whoever wrote the the button code example thought that VirtualTreeview behaved like IndexOf (which is what I would have expected too).
If you are interested, I still have an old version from 2001 on a backup , I could check it.
I see 2 options: either restore the old functionality if needed
I don't believe that an "old functionality" exits.
It looks as if it was like that from the beginning.
Well then, I can add a variant to my first option: create the functionality (since IMO it should be there).
Show quoted text 19 lines
If I read the code correctly,
> if the parameter is the root, AbsoluteIndex will answer 0.
> If the parameter is not found, AbsoluteIndex will answer 0 too.
Yes. There are 3 cases where the result is 0:
1.) Node is nil
2.) Node is the (invisible) root node
3.) Node is the first (visible) node
All of them result in zero so these cases cannot be
distinguished by the function result.
> Is this deliberate?
That's the question.
But I don't think that it was different at any time.
And it seems that as long as this is not changed in VirtualTreeView
the if statement in the example on the Free Pascal page is nonsense.
In the current state of the code, I agree it is useless.