* * *

Author Topic: VirtualTreeview node.parent "illegaler qualifier"  (Read 432 times)

nogo

  • New member
  • *
  • Posts: 5
VirtualTreeview node.parent "illegaler qualifier"
« on: August 15, 2017, 02:45:51 pm »
Hello,

just try to follow the example from Lischke's book: "Treeview tutorial"

Quote
Determine the parent
Every node (PVirtualNode) has the property parent. This property points to the parent of
the node. The parent property of a root-node will point to the tree. To differentiate a
root-node from a normal node you can use the following:
Code: Pascal  [Select]
  1. var
  2. Node: PVirtualNode;
  3. begin
  4. if not Assigned(vst.FocusedNode) then
  5. exit;
  6. Node:=vst.FocusedNode;
  7. while vst.GetNodeLevel(Node)>0 do
  8. Node:=Node.Parent;
  9. end;


Coming from a bigger project, I've broken it down to a small project:
One VirtualStringTree, one button and this code:

Code: Pascal  [Select]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3. node: PVirtualNode;
  4.  
  5. begin
  6.   node:= VirtualStringTree1.AddChild(nil);
  7.   node:= VirtualStringTree1.AddChild(node);
  8.   node:=node.
  9. end;                          
  10.  


Now the question:

just entering the last "." waiting for the List just failure occurs with "illegal qualifier".
What do I do wrong?


taazz

  • Hero Member
  • *****
  • Posts: 4486
Re: VirtualTreeview node.parent "illegaler qualifier"
« Reply #1 on: August 15, 2017, 03:01:24 pm »
just entering the last "." waiting for the List just failure occurs with "illegal qualifier".
What do I do wrong?
You do not dereference the pointer variable eg.

Code: Pascal  [Select]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3. node: PVirtualNode;
  4.  
  5. begin
  6.   node:= VirtualStringTree1.AddChild(nil);
  7.   node:= VirtualStringTree1.AddChild(node);
  8.   node:=node^.
  9. end;                          
  10.  
note the "^" character before the "." character. In delphi mode the compiler will auto dereference typed pointer variables for you the same way it dereferences object variables for you. In fpc mode you have to do it manually.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

nogo

  • New member
  • *
  • Posts: 5
Re: VirtualTreeview node.parent "illegaler qualifier"
« Reply #2 on: August 16, 2017, 08:29:01 am »
Many thanks taazz,

now I do understand and can carry on,

regards,

nogo

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus