我在node.data里面存储的数据,取出来的时候是空的,为什么?
有人能提供一个如何取得指针变量数值的方法么?

解决方案 »

  1.   

    var P : ^string ;
    begin
      ...
      showMessage(p^)
    end ;
      

  2.   

    不是这样的,我要在每个接点那里存储数据(node.data),然后在别的地方调用这个数据。
    node.data是pointer类型的。
      

  3.   

    for example
    如果你的node.data里面存储的是一个类的数据(TFileData)
    用下面的方法取数据
    TFileData(Node.data).Property;propert为tfiledata的属性
      

  4.   

    里面放的是库里面的一个字段值string类型.但是node.data是pointer的,强制转换也不行。
      

  5.   

    var
      rootNode: TTreeNode;
      pModule: ^CModuleObject;
      i: integer;
    begin
      self.query:=query;
      self.tree:=tree;
      tree.Items.Clear;
      new(pModule);
      pModule^:=CModuleObject.create(0,'***',MODULE_FOLDER);
      rootNode:=tree.Items.AddObject(nil, pModule^.innerName, pModule);
      getNode(rootNode, pModule^.innerCode);
      rootNode.Expand(true);
      for i:=0 to rootNode.Count-1 do
        rootNode.Item[i].Collapse(true);
    end;
      

  6.   

    给你帮助里的例子,有解释The following code defines a record type of TMyRec and a record pointer type of PMyRec.type
    PMyRec = ^TMyRec;
    TMyRec = record
      FName: string;
      LName: string;
    end;Assuming these types are used, the following code adds a node to TreeView1 as the last sibling of a specified node. A TMyRec record is associated with the added item. The FName and LName fields are obtained from edit boxes Edit1 and Edit2. The Index parameter is obtained from edit box Edit3. The item is added only if the Index is a valid value.procedure TForm1.Button1Click(Sender: TObject);var
      MyRecPtr: PMyRec;
      TreeViewIndex: LongInt;
    begin
      New(MyRecPtr);
      MyRecPtr^.FName := Edit1.Text;
      MyRecPtr^.LName := Edit2.Text;
      TreeViewIndex := StrToInt(Edit3.Text);
      with TreeView1 do
      begin
        if Items.Count = 0 then
          Items.AddObject(nil, 'Item' + IntToStr(TreeViewIndex), MyRecPtr)
        else if (TreeViewIndex < Items.Count) and (TreeViewIndex >= 0) then      Items.AddObject(Items[TreeViewIndex], 'Item' + IntToStr(TreeViewIndex), MyRecPtr);
      end;
    end;After an item containing a TMyRec record has been added, the following code retrieves the FName and LName values associated with the item and displays the values in a label.procedure TForm1.Button2Click(Sender: TObject);begin
      Label1.Caption := PMyRec(TreeView1.Selected.Data)^.FName + ' ' +
                      PMyRec(TreeView1.Selected.Data)^.LName;
    end;