[Lazarus] VirtualTreeView, Absoluteindex example on freepascal.org
Jürgen Hestermann
juergen.hestermann at gmx.de
Wed Sep 11 18:05:31 CEST 2013
On
http://wiki.freepascal.org/VirtualTreeview_Example_for_Lazarus
there is the following example procedure:
------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
Var
Data: PTreeData;
XNode: PVirtualNode;
Rand: Integer;
Begin
Randomize;
Rand := Random(99);
XNode:=VST.AddChild(nil);
if VST.AbsoluteIndex(XNode) > -1 then
Begin
Data := VST.GetNodeData(Xnode);
Data^.Column0:= 'One ' + IntToStr(Rand);
Data^.Column1:= 'Two ' + IntToStr(Rand + 10);
Data^.Column2:= 'Three ' + IntToStr(Rand - 10);
End;
End;
------------------------------------------------
Can someone explain what the line
if VST.AbsoluteIndex(XNode) > -1 then
actually means?
The method AbsoluteIndex gives back a Cardinal so how can it be less than 0?
Therefore the if statement is completely useless because it is always true.
BTW: I was pointed to this because Lazarus (or FPC?) showed me a compiling
message that this line will cause a type convertion to 64 bit (well done!).
More information about the Lazarus
mailing list